human
I am working on the file "Projects/mcmc/first_day.ipynb".
The first task is:
Now I can compute the loglike in the same way as for the union2.1 data. Just copy the loglike function from before, add as params
 - OmDE
 - alpha
 - beta
 - M_b
For the covariance matrix use the function from before, and instead of the "zandmu" variable use jla_dataset
Can you write Python code for it?
assistant
#Here is Python code to compute the loglike in the same way as for the union2.

 def loglike_jla(params,h=0.7):
    """
    This function computes the logarithm of the likelihood. It recieves a vector
    params-> vector with three components (Omega Dark Energy, alpha, beta and M_b)
    """
    OmDE = params[0]
    alpha = params[1]
    beta = params[2]
    MB = params[3]
    covariance = mu_cov(alpha, beta)
    inv_covariance=np.linalg.inv(covariance)
# Ahora quiero calcular la diferencia entre el valor reportado y el calculado
    mu_obs = jla_dataset['mb']-(MB-alpha*jla_dataset['x1']+beta*jla_dataset['color'])
    mu_teo = 5.*np.log10(dl(jla_dataset['zcmb'],OmDE,h))+25
    delta = mu_teo - mu_obs
    chisquare = np.dot(delta,np.dot(inv_covariance,delta))
    return -chisquare/2

param = [0.65,0.13,3.1,-20]
loglike_jla(param)

param = [0.7,0.13,3.1,-19]
loglike_jla(param)