当前位置: 首页>>代码示例>>Python>>正文


Python Eq.__class__方法代码示例

本文整理汇总了Python中sympy.Eq.__class__方法的典型用法代码示例。如果您正苦于以下问题:Python Eq.__class__方法的具体用法?Python Eq.__class__怎么用?Python Eq.__class__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sympy.Eq的用法示例。


在下文中一共展示了Eq.__class__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: probability

# 需要导入模块: from sympy import Eq [as 别名]
# 或者: from sympy.Eq import __class__ [as 别名]
 def probability(self, condition, **kwargs):
     cond_inv = False
     if isinstance(condition, Ne):
         condition = Eq(condition.args[0], condition.args[1])
         cond_inv = True
     expr = condition.lhs - condition.rhs
     rvs = random_symbols(expr)
     z = Dummy('z', real=True, Finite=True)
     dens = self.compute_density(expr)
     if any([pspace(rv).is_Continuous for rv in rvs]):
         from sympy.stats.crv import (ContinuousDistributionHandmade,
             SingleContinuousPSpace)
         if expr in self.values:
             # Marginalize all other random symbols out of the density
             randomsymbols = tuple(set(self.values) - frozenset([expr]))
             symbols = tuple(rs.symbol for rs in randomsymbols)
             pdf = self.domain.integrate(self.pdf, symbols, **kwargs)
             return Lambda(expr.symbol, pdf)
         dens = ContinuousDistributionHandmade(dens)
         space = SingleContinuousPSpace(z, dens)
         result = space.probability(condition.__class__(space.value, 0))
     else:
         from sympy.stats.drv import (DiscreteDistributionHandmade,
             SingleDiscretePSpace)
         dens = DiscreteDistributionHandmade(dens)
         space = SingleDiscretePSpace(z, dens)
         result = space.probability(condition.__class__(space.value, 0))
     return result if not cond_inv else S.One - result
开发者ID:gamechanger98,项目名称:sympy,代码行数:30,代码来源:rv.py

示例2: probability

# 需要导入模块: from sympy import Eq [as 别名]
# 或者: from sympy.Eq import __class__ [as 别名]
    def probability(self, condition, **kwargs):
        z = Dummy('z', real=True, finite=True)
        cond_inv = False
        if isinstance(condition, Ne):
            condition = Eq(condition.args[0], condition.args[1])
            cond_inv = True
        # Univariate case can be handled by where
        try:
            domain = self.where(condition)
            rv = [rv for rv in self.values if rv.symbol == domain.symbol][0]
            # Integrate out all other random variables
            pdf = self.compute_density(rv, **kwargs)
            # return S.Zero if `domain` is empty set
            if domain.set is S.EmptySet or isinstance(domain.set, FiniteSet):
                return S.Zero if not cond_inv else S.One
            if isinstance(domain.set, Union):
                return sum(
                     Integral(pdf(z), (z, subset), **kwargs) for subset in
                     domain.set.args if isinstance(subset, Interval))
            # Integrate out the last variable over the special domain
            return Integral(pdf(z), (z, domain.set), **kwargs)

        # Other cases can be turned into univariate case
        # by computing a density handled by density computation
        except NotImplementedError:
            from sympy.stats.rv import density
            expr = condition.lhs - condition.rhs
            dens = density(expr, **kwargs)
            if not isinstance(dens, ContinuousDistribution):
                dens = ContinuousDistributionHandmade(dens)
            # Turn problem into univariate case
            space = SingleContinuousPSpace(z, dens)
            result = space.probability(condition.__class__(space.value, 0))
            return result if not cond_inv else S.One - result
开发者ID:Lenqth,项目名称:sympy,代码行数:36,代码来源:crv.py

示例3: probability

# 需要导入模块: from sympy import Eq [as 别名]
# 或者: from sympy.Eq import __class__ [as 别名]
 def probability(self, condition):
     complement = isinstance(condition, Ne)
     if complement:
         condition = Eq(condition.args[0], condition.args[1])
     try:
         _domain = self.where(condition).set
         if condition == False or _domain is S.EmptySet:
             return S.Zero
         if condition == True or _domain == self.domain.set:
             return S.One
         prob = self.eval_prob(_domain)
     except NotImplementedError:
         from sympy.stats.rv import density
         expr = condition.lhs - condition.rhs
         dens = density(expr)
         if not isinstance(dens, DiscreteDistribution):
             dens = DiscreteDistributionHandmade(dens)
         z = Dummy('z', real = True)
         space = SingleDiscretePSpace(z, dens)
         prob = space.probability(condition.__class__(space.value, 0))
     if (prob == None):
         prob = Probability(condition)
     return prob if not complement else S.One - prob
开发者ID:normalhuman,项目名称:sympy,代码行数:25,代码来源:drv.py


注:本文中的sympy.Eq.__class__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。