Page 1 of 1
COSMOMC as a generic sampler
Posted: July 19 2009
by Bruna Santos
Deal All,
I'm trying to use COSMOMC as a generic sampler, but I'm having some problems. As mentioned in
http://cosmologist.info/cosmomc/readme.html, I've preformed the changes require, but I don't know how to change the GenericLikelihoodFunction and then running it. Could anyone help me with this, by giving me a specific example? I also downloaded Cosmologui, but I' don't know if this is produces the same results than using COSMOMC as a generic sampler. And I would like to know if in cosmologui it is possible to change the likelihood function and how to do it.
Could anyone help me with this question by giving me a specific example?
Thank you all,
Bruna Santos
Re: COSMOMC as a generic sampler
Posted: July 20 2009
by Antony Lewis
Cosmologui is for looking at samples, not generating them.
GenericLikelihoodFunction is in CalcLike.f90.
COSMOMC as a generic sampler
Posted: July 20 2009
by Bruna Santos
Thank for your help, Antony.
Could anyone say to me how put the function and params in CalcLike.f90?
Could anyone help me with this question by giving me a specific example?
Thank you all,
Bruna Santos
COSMOMC as a generic sampler
Posted: July 21 2009
by Tess Jaffe
I'm not sure exactly what you're asking, but I just modified the GenericLikelihoodFunction function in calclike.f90 around line 35. You take out the lines
GenericLikelihoodFunction = LogZero
stop 'GenericLikelihoodFunction: need to write this function!'
and instead add lines like
call my_like(Params%P,num_hard,thisval)
GenericLikelihoodFunction = thisval
The function "my_like" should expect a pointer to float type (i.e. a list of floats) as the first parameter, an integer specifying how many parameters there are (hard-wired), and lastly a pointer to a float where it should return the value of -ln(likelihood).
I'm no Fortran programmer, so in my case, my_like is a C++ function. But it's the same in that you just then link in the corresponding object file when you compile cosmomc.
Does that answer your question?
COSMOMC as a generic sampler
Posted: July 22 2009
by Shaun Thomas
In calclike.f90 I have:
contains
function GenericLikelihoodFunction(Params)
type(ParamSet) Params
real :: GenericLikelihoodFunction
call lensing_likelihood(Params%P(1),Params%P(2),GenericLikelihoodFunction)
print *, 'genericlikelihood is:', GenericLikelihoodFunction
end function GenericLikelihoodFunction
This likelihood function is a C++ function of mine and so I'd define it:
extern "C" {
void lensing_likelihood_(float *omega_m, float *sigma_8, float *result){
double log_likelihood;
[do some stuff]
*result = (float)log_likelihood;
}
}
elsewhere in my code. In settings.f90 make sure you have something like:
logical, parameter :: generic_mcmc= .true.
integer, parameter :: num_hard = 2
integer, parameter :: num_initpower = 0
integer, parameter :: num_norm = 0
where 2 is the number of parameters (for example) you have in your function (Params%P(1),Params%P(2))
Remember to compile with Makefile_nowmap and you'll still need to compile camb. If you're still having issues try checking you have,
use_CMB = F
use_HST = F
use_mpk = F
in your params.ini. As stated above cosmoloGUI will just analyse your chains. It doesn't care what they are - wmap, crop circle distribution...
good luck - shaun