Example #1
0
 def f_and_h(self):  #计算成员的f
     self.f = 1 - nm(0, 1).cdf(self.xi)
     self.h = 1 - nm(0, 1).cdf(self.xi - self.di)
     self.c = 1 - self.f
Example #2
0
	priors.JeffreysPrior : (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([0., -np.inf, np.inf, 3., 3.]),
	priors.JeffreysPrior : 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([nm(0,1).pdf(0), 0., 0., nm(0,1).pdf(3), nm(0,1).pdf(-3)]),
	priors.JeffreysPrior : 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.])
}


def test_draw_samples():
	""" 
	Test basic functionality of `draw_samples()` method of each `Prior` class.
	"""
	for Prior in initialization_inputs.keys():
		inputs = initialization_inputs[Prior]

		TestPrior = Prior(*inputs)
Example #3
0
Teff = (4444.2, 160) 
logg = (3.0, 0.5)
feh = (0.0, 0.25)
parallax = (31.92,0.05)

# age from BJ's Specmatch-Gaia results
age = [9.9,0.1] # log10(age in yr)

mist = MIST_Isochrone()
model  = StarModel(mist, Teff=Teff, logg=logg, feh=feh, parallax=parallax, age=age, use_emcee=True)
model.fit(niter=1000)

# add in prior on age
age_post = model.samples.age_0

age_prior_probs = nm(age[0],age[1]).pdf(age_post)
compare = np.random.uniform(size=len(age_post))

new_samples = model.samples.loc[age_prior_probs > compare]
new_samples = new_samples[['mass_0_0','radius_0_0','feh_0','age_0','distance_0']]

# make figure
corner.corner(
	new_samples,
	labels=['Mass [Msol]','Radius [Rsol]','Fe/H','log10(age [Gyr])','distance [pc]'],
	quantiles=[0.16, 0.5, 0.84],
    show_titles=True
)
plt.savefig('isochrones_corner.png', dpi=250)

# save results
Example #4
0
	priors.JeffreysPrior : (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.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.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.])
}


def test_draw_samples():
	""" 
	Test basic functionality of `draw_samples()` method of each `Prior` class.
	"""
	for Prior in initialization_inputs.keys():
		inputs = initialization_inputs[Prior]

		TestPrior = Prior(*inputs)
Example #5
0
    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.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.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.])
}


def test_draw_samples():
    """ 
	Test basic functionality of `draw_samples()` method of each `Prior` class.
Example #6
0
d = input('memberd:')
c = input('memberc:')
d = float(d)
c = float(c)
l = c + d / 2

plt.figure(figsize=(12, 3))
plt.xlim((-7, 7))
plt.ylim((0, 0.5))

new_tickes = np.arange(-7, 7, 0.5)
plt.xticks(new_tickes)
plt.yticks([])

x1 = np.arange(-4, 4, 0.001)
y1 = nm(0, 1).pdf(x1)
plt.plot(x1, y1, color='r', linewidth=2)

x2 = np.arange(d - 4, d + 4, 0.001)
y2 = nm(d, 1).pdf(x2)
plt.plot(x2, y2, color='b', linewidth=2)

x3 = [l, l]
y3 = [0, 0.5]
plt.plot(x3, y3, color='k', linewidth=2)

ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.spines['left'].set_color('none')
ax.xaxis.set_ticks_position('bottom')