COSMOMC as a generic sampler
-
- Posts: 3
- Joined: February 10 2009
- Affiliation: Centro Astrofisica UP
COSMOMC as a generic sampler
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
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
-
- Posts: 1941
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: COSMOMC as a generic sampler
Cosmologui is for looking at samples, not generating them.
GenericLikelihoodFunction is in CalcLike.f90.
GenericLikelihoodFunction is in CalcLike.f90.
-
- Posts: 3
- Joined: February 10 2009
- Affiliation: Centro Astrofisica UP
COSMOMC as a generic sampler
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
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
-
- Posts: 7
- Joined: March 11 2005
- Affiliation: Centre d'Etude Spatiale des Rayonnements
COSMOMC as a generic sampler
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?
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?
-
- Posts: 3
- Joined: October 26 2006
- Affiliation: University College London (UCL)
COSMOMC as a generic sampler
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
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