python求gamma分布_Pythonstats.gamma方法代码示例

python求gamma分布_Pythonstats.gamma⽅法代码⽰例本⽂整理汇总了Python中scipy.stats.gamma⽅法的典型⽤法代码⽰例。如果您正苦于以下问题:Python stats.gamma⽅法的具体⽤法?Python stats.gamma怎么⽤?Python stats.gamma使⽤的例⼦?那么恭喜您, 这⾥精选的⽅法代码⽰例或许可以为您提供帮助。您也可以进⼀步了解该⽅法所在模块scipy.stats的⽤法⽰例。
在下⽂中⼀共展⽰了stats.gamma⽅法的27个代码⽰例,这些例⼦默认根据受欢迎程度排序。您可以为喜欢或者感觉有⽤的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码⽰例。
⽰例1: __init__
点赞 6
# 需要导⼊模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import gamma [as 别名]
def __init__(self,
basis=LinearBasis(),
var=Parameter(gamma(1.), Positive()),
tol=1e-8,
maxiter=1000,
nstarts=100,
random_state=None
):
"""See class docstring."""
self.basis = basis
self.var = var
self.maxiter = maxiter
self.nstarts = nstarts
self.random_state = random_state
self.random_ = check_random_state(random_state)
开发者ID:NICTA,项⽬名称:revrand,代码⾏数:18,
⽰例2: __init__
点赞 6
# 需要导⼊模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import gamma [as 别名]
def __init__(self,
nbases,
Xdim,
mean=Parameter(norm_dist(), Bound()),
lenscale=Parameter(gamma(1.), Positive()),
regularizer=None,
random_state=None
):
"""See this class's docstring."""
self.random_state = random_state # for repr
self._random = check_random_state(random_state)
self._init_dims(nbases, Xdim)
self._params = [self._init_param(mean),
self._init_param(lenscale)]
self._init_matrices()
super(_LengthScaleBasis, self).__init__(regularizer)
开发者ID:NICTA,项⽬名称:revrand,代码⾏数:18,
⽰例3: test_grad_concat
点赞 6
# 需要导⼊模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import gamma [as 别名]
def test_grad_concat(make_gaus_data):
X, _, _, _ = make_gaus_data
N, d = X.shape
base = bs.LinearBasis(onescol=False) + bs.LinearBasis(onescol=False) assert ad(X)) == []
base += bs.RadialBasis(centres=X)
s7520G = ad(X, 1.)
assert list(G)[0].shape == (N, N + 2 * d)
D = 200
base += bs.RandomRBF(nbases=D, Xdim=d,
lenscale=Parameter(gamma(1), Positive(), shape=(d,)))
G = ad(X, 1., np.ones(d))
dims = [(N, N + (D + d) * 2), (N, N + (D + d) * 2, d)]
for g, d in zip(G, dims):
assert g.shape == d
开发者ID:NICTA,项⽬名称:revrand,代码⾏数:25,
⽰例4: test_logstruc_params
点赞 6
# 需要导⼊模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import gamma [as 别名]
def test_logstruc_params(make_quadratic, make_random):
random = make_random
a, b, c, data, _ = make_quadratic
w0 = [Parameter(random.gamma(2, size=(2,)), Positive()),
Parameter(random.randn(), Bound())
]
qobj_struc = lambda w12, w3, data: q_struc(w12, w3, data, qobj)
assert_opt = lambda Eab, Ec: \
np.allclose((a, b, c), (Eab[0], Eab[1], Ec), atol=1e-3, rtol=0)
nmin = structured_minimizer(logtrick_minimizer(minimize))迪尼格尔
res = nmin(qobj_struc, w0, args=(data,), jac=True, method='L-BFGS-B')
assert_opt(*res.x)
nsgd = structured_sgd(logtrick_sgd(sgd))
res = nsgd(qobj_struc, w0, data, eval_obj=True, random_state=make_random) assert_opt(*res.x)
qf_struc = lambda w12, w3, data: q_struc(w12, w3, data, qfun)
qg_struc = lambda w12, w3, data: q_struc(w12, w3, data, qgrad)
res = nmin(qf_struc, w0, args=(data,), jac=qg_struc, method='L-BFGS-B') assert_opt(*res.x)
开发者ID:NICTA,项⽬名称:revrand,代码⾏数:27,
⽰例5: setUp_configure
点赞 6
# 需要导⼊模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import gamma [as 别名]
def setUp_configure(self):
记住回家的路
from scipy import stats
self.dist = distributions.Gamma
self.scipy_dist = stats.gamma
['batch_shape', 'entropy', 'event_shape', 'log_prob', 'mean',
'sample', 'support', 'variance'])
k = utils.force_array(
numpy.random.uniform(0, 5, self.shape).astype(numpy.float32))
theta = utils.force_array(
numpy.random.uniform(0, 5, self.shape).astype(numpy.float32))
self.params = {'k': k, 'theta': theta}
self.scipy_params = {'a': k, 'scale': theta}
self.support = 'positive'
开发者ID:chainer,项⽬名称:chainer,代码⾏数:19,
⽰例6: test_expect
点赞 6
# 需要导⼊模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import gamma [as 别名]
def test_expect(self):
# smoke test the expect method of the frozen distribution
# only take a gamma w/loc and scale and poisson with loc specified
def func(x):
return x
gm = stats.gamma(a=2, loc=3, scale=4)
gm_val = gm.expect(func, lb=1, ub=2, conditional=True)
gamma_val = pect(func, args=(2,), loc=3, scale=4,
lb=1, ub=2, conditional=True)
assert_allclose(gm_val, gamma_val)
p = stats.poisson(3, loc=4)
p_val = p.expect(func)
poisson_val = pect(func, args=(3,), loc=4)
assert_allclose(p_val, poisson_val)
开发者ID:Relph1119,项⽬名称:GraphicDesignPatternByPython,代码⾏数:18,⽰例7: test_erlang_runtimewarning
点赞 6
# 需要导⼊模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import gamma [as 别名]
def test_erlang_runtimewarning(self):
# erlang should generate a RuntimeWarning if a non-integer
# shape parameter is used.
with warnings.catch_warnings():
warnings.simplefilter("error", RuntimeWarning)
# The non-integer shape parameter 1.3 should trigger a
# RuntimeWarning
assert_raises(RuntimeWarning,
# Calling the fit method with `f0` set to an integer should
# *not* trigger a RuntimeWarning. It should return the same
# values as gamma.fit(...).
data = [0.5, 1.0, 2.0, 4.0]
result_erlang = lang.fit(data, f0=1)
result_gamma = stats.gamma.fit(data, f0=1)
ar3
东升镇高级中学
assert_allclose(result_erlang, result_gamma, rtol=1e-3)
开发者ID:Relph1119,项⽬名称:GraphicDesignPatternByPython,代码⾏数:20,⽰例8: testGammaLogPDF
点赞 6
# 需要导⼊模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import gamma [as 别名]
def testGammaLogPDF(self):
activex控件是什么st_session():
batch_size = 6
alpha = tf.constant([2.0] * batch_size)
beta = tf.constant([3.0] * batch_size)
alpha_v = 2.0
beta_v = 3.0
x = np.array([2.5, 2.5, 4.0, 0.1, 1.0, 2.0], dtype=np.float32)

本文发布于:2024-09-21 21:49:54,感谢您对本站的认可!

本文链接:https://www.17tex.com/xueshu/475513.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:代码   名称   有助于
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议