Skip to content

Commit

Permalink
Merge pull request #120 from sblunt/mynameisjeff
Browse files Browse the repository at this point in the history
Rename JeffreysPrior to LogUniformPrior
  • Loading branch information
sblunt committed Jul 11, 2019
2 parents a8bee56 + 701bf5d commit 33a6f09
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions orbitize/priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def compute_lnprob(self, element_array):

return lnprob

class JeffreysPrior(Prior):
class LogUniformPrior(Prior):
"""
This is the probability distribution :math:`p(x) \\propto 1/x`
Expand All @@ -128,7 +128,7 @@ def __init__(self, minval, maxval):
self.logmax = np.log(maxval)

def __repr__(self):
return "Jeffreys"
return "Log Uniform"

def draw_samples(self, num_samples):
"""
Expand All @@ -150,7 +150,7 @@ def draw_samples(self, num_samples):

def compute_lnprob(self, element_array):
"""
Compute the prior probability of each element given that its drawn from a Jeffreys prior
Compute the prior probability of each element given that its drawn from a Log-Uniofrm prior
Args:
element_array (float or np.array of float): array of paramters to compute the prior probability of
Expand Down
4 changes: 2 additions & 2 deletions orbitize/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __init__(self, num_secondary_bodies, data_table, system_mass,

for body in np.arange(num_secondary_bodies):
# Add semimajor axis prior
self.sys_priors.append(priors.JeffreysPrior(0.001, 1e7))
self.sys_priors.append(priors.LogUniformPrior(0.001, 1e7))
self.labels.append('sma{}'.format(body+1))

# Add eccentricity prior
Expand Down Expand Up @@ -135,7 +135,7 @@ def __init__(self, num_secondary_bodies, data_table, system_mass,

if self.fit_secondary_mass:
for body in np.arange(num_secondary_bodies):
self.sys_priors.append(priors.JeffreysPrior(1e-6, 1)) # in Solar masses for onw
self.sys_priors.append(priors.LogUniformPrior(1e-6, 1)) # in Solar masses for onw

if mass_err > 0:
self.sys_priors.append(priors.GaussianPrior(system_mass, mass_err))
Expand Down
8 changes: 4 additions & 4 deletions tests/test_priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@

initialization_inputs = {
priors.GaussianPrior : [1000., 1.],
priors.JeffreysPrior : [1., 2.],
priors.LogUniformPrior : [1., 2.],
priors.UniformPrior : [0., 1.],
priors.SinPrior : [],
priors.LinearPrior : [-2., 2.]
}

expected_means_mins_maxes = {
priors.GaussianPrior : (1000.,0.,np.inf),
priors.JeffreysPrior : (1/np.log(2),1., 2.),
priors.LogUniformPrior : (1/np.log(2),1., 2.),
priors.UniformPrior : (0.5, 0., 1.),
priors.SinPrior : (np.pi/2., 0., np.pi),
priors.LinearPrior : (1./3.,0.,1.0)
}

lnprob_inputs = {
priors.GaussianPrior : np.array([-3.0, np.inf, 1000., 999.]),
priors.JeffreysPrior : np.array([-1., 0., 1., 1.5, 2., 2.5]),
priors.LogUniformPrior : np.array([-1., 0., 1., 1.5, 2., 2.5]),
priors.UniformPrior : np.array([0., 0.5, 1., -1., 2.]),
priors.SinPrior : np.array([0., np.pi/2., np.pi, 10., -1.]),
priors.LinearPrior : np.array([0., 0.5, 1., 2., -1.])
}

expected_probs = {
priors.GaussianPrior : np.array([0., 0., nm(1000.,1.).pdf(1000.), nm(1000.,1.).pdf(999.)]),
priors.JeffreysPrior : np.array([0., 0., 1., 2./3., 0.5, 0.])/np.log(2),
priors.LogUniformPrior : np.array([0., 0., 1., 2./3., 0.5, 0.])/np.log(2),
priors.UniformPrior : np.array([1., 1., 1., 0., 0.]),
priors.SinPrior : np.array([0., 0.5, 0., 0., 0.]),
priors.LinearPrior : np.array([2., 1., 0., 0., 0.])
Expand Down

0 comments on commit 33a6f09

Please sign in to comment.