本文整理汇总了Python中sympy.stats.covariance函数的典型用法代码示例。如果您正苦于以下问题:Python covariance函数的具体用法?Python covariance怎么用?Python covariance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了covariance函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_multiple_normal
def test_multiple_normal():
X, Y = Normal('x', 0, 1), Normal('y', 0, 1)
assert E(X + Y) == 0
assert variance(X + Y) == 2
assert variance(X + X) == 4
assert covariance(X, Y) == 0
assert covariance(2*X + Y, -X) == -2*variance(X)
assert E(X, Eq(X + Y, 0)) == 0
assert variance(X, Eq(X + Y, 0)) == S.Half
开发者ID:archipleago-creature,项目名称:sympy,代码行数:11,代码来源:test_continuous_rv.py
示例2: test_dice
def test_dice():
# TODO: Make iid method!
X, Y, Z = Die('X', 6), Die('Y', 6), Die('Z', 6)
a, b = symbols('a b')
assert E(X) == 3 + S.Half
assert variance(X) == S(35)/12
assert E(X + Y) == 7
assert E(X + X) == 7
assert E(a*X + b) == a*E(X) + b
assert variance(X + Y) == variance(X) + variance(Y) == cmoment(X + Y, 2)
assert variance(X + X) == 4 * variance(X) == cmoment(X + X, 2)
assert cmoment(X, 0) == 1
assert cmoment(4*X, 3) == 64*cmoment(X, 3)
assert covariance(X, Y) == S.Zero
assert covariance(X, X + Y) == variance(X)
assert density(Eq(cos(X*S.Pi), 1))[True] == S.Half
assert correlation(X, Y) == 0
assert correlation(X, Y) == correlation(Y, X)
assert smoment(X + Y, 3) == skewness(X + Y)
assert smoment(X, 0) == 1
assert P(X > 3) == S.Half
assert P(2*X > 6) == S.Half
assert P(X > Y) == S(5)/12
assert P(Eq(X, Y)) == P(Eq(X, 1))
assert E(X, X > 3) == 5 == moment(X, 1, 0, X > 3)
assert E(X, Y > 3) == E(X) == moment(X, 1, 0, Y > 3)
assert E(X + Y, Eq(X, Y)) == E(2*X)
assert moment(X, 0) == 1
assert moment(5*X, 2) == 25*moment(X, 2)
assert P(X > 3, X > 3) == S.One
assert P(X > Y, Eq(Y, 6)) == S.Zero
assert P(Eq(X + Y, 12)) == S.One/36
assert P(Eq(X + Y, 12), Eq(X, 6)) == S.One/6
assert density(X + Y) == density(Y + Z) != density(X + X)
d = density(2*X + Y**Z)
assert d[S(22)] == S.One/108 and d[S(4100)] == S.One/216 and S(3130) not in d
assert pspace(X).domain.as_boolean() == Or(
*[Eq(X.symbol, i) for i in [1, 2, 3, 4, 5, 6]])
assert where(X > 3).set == FiniteSet(4, 5, 6)
开发者ID:MCGallaspy,项目名称:sympy,代码行数:45,代码来源:test_finite_rv.py
示例3: test_multiple_normal
def test_multiple_normal():
X, Y = Normal('x', 0, 1), Normal('y', 0, 1)
assert E(X + Y) == 0
assert variance(X + Y) == 2
assert variance(X + X) == 4
assert covariance(X, Y) == 0
assert covariance(2*X + Y, -X) == -2*variance(X)
assert skewness(X) == 0
assert skewness(X + Y) == 0
assert correlation(X, Y) == 0
assert correlation(X, X + Y) == correlation(X, X - Y)
assert moment(X, 2) == 1
assert cmoment(X, 3) == 0
assert moment(X + Y, 4) == 12
assert cmoment(X, 2) == variance(X)
assert smoment(X*X, 2) == 1
assert smoment(X + Y, 3) == skewness(X + Y)
assert E(X, Eq(X + Y, 0)) == 0
assert variance(X, Eq(X + Y, 0)) == S.Half
开发者ID:vprusso,项目名称:sympy,代码行数:20,代码来源:test_continuous_rv.py
示例4: test_dice
def test_dice():
X, Y, Z = Die(6), Die(6), Die(6)
a, b = symbols("a b")
assert E(X) == 3 + S.Half
assert variance(X) == S(35) / 12
assert E(X + Y) == 7
assert E(X + X) == 7
assert E(a * X + b) == a * E(X) + b
assert variance(X + Y) == variance(X) + variance(Y)
assert variance(X + X) == 4 * variance(X)
assert covariance(X, Y) == S.Zero
assert covariance(X, X + Y) == variance(X)
assert density(Eq(cos(X * S.Pi), 1))[True] == S.Half
assert P(X > 3) == S.Half
assert P(2 * X > 6) == S.Half
assert P(X > Y) == S(5) / 12
assert P(Eq(X, Y)) == P(Eq(X, 1))
assert E(X, X > 3) == 5
assert E(X, Y > 3) == E(X)
assert E(X + Y, Eq(X, Y)) == E(2 * X)
assert E(X + Y - Z, 2 * X > Y + 1) == S(49) / 12
assert P(X > 3, X > 3) == S.One
assert P(X > Y, Eq(Y, 6)) == S.Zero
assert P(Eq(X + Y, 12)) == S.One / 36
assert P(Eq(X + Y, 12), Eq(X, 6)) == S.One / 6
assert density(X + Y) == density(Y + Z) != density(X + X)
d = density(2 * X + Y ** Z)
assert d[S(22)] == S.One / 108 and d[S(4100)] == S.One / 216 and S(3130) not in d
assert pspace(X).domain.as_boolean() == Or(*[Eq(X.symbol, i) for i in [1, 2, 3, 4, 5, 6]])
assert where(X > 3).set == FiniteSet(4, 5, 6)
开发者ID:BDGLunde,项目名称:sympy,代码行数:37,代码来源:test_finite_rv.py
示例5: doit
def doit(self, **kwargs):
return covariance(self.args[0], self.args[1], self._condition, **kwargs)
开发者ID:AStorus,项目名称:sympy,代码行数:2,代码来源:symbolic_probability.py
示例6: _eval_rewrite_as_Integral
def _eval_rewrite_as_Integral(self, arg1, arg2, condition=None):
return covariance(self.args[0], self.args[1], self._condition, evaluate=False)
开发者ID:AlexanderKulka,项目名称:sympy,代码行数:2,代码来源:symbolic_probability.py
注:本文中的sympy.stats.covariance函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论