timothydmorton / isochrones

Pythonic stellar model grid access; easy MCMC fitting of stellar properties
http://isochrones.readthedocs.org
MIT License
120 stars 62 forks source link

fix the Chabrier prior #123

Closed segasai closed 4 years ago

segasai commented 4 years ago

Hi,

The Chabrier prior is incorrect. there is a missing log(10) factor there. Here is the illustration (the chabrier 2003 imf is defined such that Mean of log10(mass) is log10(0.079) and stddev of log10(mass) is 0.69)

Here is what you currently use for Chabrier:

In [18]: 10**np.log10(isochrones.priors.LogNormalPrior(np.log(0.079),.69).sample(100000)).mean()                                                
Out[18]: 0.07869121411187371

In [19]: 10**np.log10(isochrones.priors.LogNormalPrior(np.log(0.079),.69).sample(100000)).mean()                                                
Out[19]: 0.07915577207985923

In [20]: np.log10(isochrones.priors.LogNormalPrior(np.log(0.079),.69).sample(100000)).std()                                                     
Out[20]: 0.29955646294079435

The mean is correct but not stddev

Here is a correct form


In [21]: np.log10(isochrones.priors.LogNormalPrior(np.log(0.079),.69*np.log(10)).sample(100000)).std()                                          
Out[21]: 0.6891607889864645

I attach the bug fix. (and thanks for the nice software!) Sergey

timothydmorton commented 4 years ago

Sweet, thanks!