Closed dfm closed 4 years ago
To handle the first, we can just cast to float64
on initialization to avoid that. The second, however, doesn't seem to have anything to do with dtypes(!):
import isochrones
import numpy as np
mod1 = isochrones.SingleStarModel(isochrones.get_ichrone("mist", bands=["G", "BP"]),
G=(12.5, 0.1),
BP=(12.5, 0.1))
mod2 = isochrones.SingleStarModel(isochrones.get_ichrone("mist", bands=["G", "BP"]),
G=(12.5, 0.1),
BP=(12.5, 0.1))
mod3 = isochrones.SingleStarModel(isochrones.get_ichrone("mist", bands=["G", "BP"]),
G=(12.5, 0.1),
BP=(12.5, 0.1))
mod4 = isochrones.SingleStarModel(isochrones.get_ichrone("mist", bands=["G", "BP"]),
G=(12.5, 0.1),
BP=(12.5, 0.1))
np.random.seed(42)
pars = np.random.rand(mod1.n_params)
mod1.mnest_prior(pars, None, None)
print(mod2.lnpost(pars) - mod1.lnpost(pars))
print(mod3.lnpost(pars) - mod2.lnpost(pars))
print(mod4.lnpost(pars) - mod3.lnpost(pars))
gives
-0.04686564768883272
0.0
0.0
In fact, it seems as though something in the call to mnest_prior
is changing something internally, as the outlier appears to be whichever object's mnest_prior
function is called. eep.
This difference also comes from the prior, not the likelihood. With the different dtypes, the difference in lnlike is on the order of 1e-5.
Fixed on master.
I came across some strange bugginess in the likelihood calculation when the dtypes of the data are inconsistent. Here are two examples:
First, if the dtypes are not the same for the different bands, numba throws an error:
Executing this, I get the following error:
Second, I would expect the following to give the same answer to at least floating point precision, but I get and error of
0.04
which (while small) is much larger than it should be and I find that it makes real differences in the results I get!