Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Statistics
New issue 4109 by [email protected]: Binomial probability density
doesn't work
http://code.google.com/p/sympy/issues/detail?id=4109
Using sympy.stats.density on a Binomial random variable results in an error
I've included a script that reproduces the error, for me
My sys.version string is '3.3.2 (v3.3.2:d047928ae3f6, May 16 2013,
00:03:43) [MSC v.1600 32 bit (Intel)]'
I'm using IPython, my IPython.__version__ string is '1.1.0'
I'm on Windows Vista
My sympy.__version__ string is '0.7.3'
The traceback is
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
C:\Python33\lib\site-packages\IPython\utils\py3compat.py in execfile(fname,
glob
, loc)
98 loc = loc if (loc is not None) else glob
99 with open(fname, 'rb') as f:
--> 100 exec(compile(f.read(), fname, 'exec'), glob, loc)
101
102 # Refactor print statements in doctests.
C:\Users\alex\Documents\grad school\Bayesian data analysis\homework
5\bug_report
.py in <module>()
4 x, y = symbols('x, y')
5 B = sympy.stats.Binomial('B', x, y)
----> 6 sympy.stats.density(B)
C:\Python33\lib\site-packages\sympy\stats\rv.py in density(expr, condition,
**kw
args)
622 Lambda(x, sqrt(2)*exp(-x**2/2)/(2*sqrt(pi)))
623 """
--> 624 return Density(expr, condition).doit(**kwargs)
625
626
C:\Python33\lib\site-packages\sympy\stats\rv.py in doit(self, **kwargs)
592 if not random_symbols(expr):
593 return Lambda(x, DiracDelta(x-expr))
--> 594 return pspace(expr).compute_density(expr, **kwargs)
595
596
C:\Python33\lib\site-packages\sympy\stats\frv.py in compute_density(self,
expr)
213
214 def compute_density(self, expr):
--> 215 expr = expr.xreplace(dict(((rs, rs.symbol) for rs in
self.values
)))
216 d = FiniteDensity()
217 for elem in self.domain:
C:\Python33\lib\site-packages\sympy\stats\rv.py in values(self)
142 @property
143 def values(self):
--> 144 return frozenset(RandomSymbol(self, sym) for sym in
self.domain.
symbols)
145
146 @property
C:\Python33\lib\site-packages\sympy\stats\frv.py in domain(self)
293 @property
294 def domain(self):
--> 295 return SingleFiniteDomain(self.symbol,
self.distribution.set)
296
297 @property
C:\Python33\lib\site-packages\sympy\stats\frv.py in set(self)
172 @property
173 def set(self):
--> 174 return list(self.density.keys())
175
176
C:\Python33\lib\site-packages\sympy\core\cache.py in wrapper(*args,
**kw_args)
90 except KeyError:
91 pass
---> 92 func_cache_it_cache[k] = r = func(*args, **kw_args)
93 return r
94 return wrapper
C:\Python33\lib\site-packages\sympy\stats\frv_types.py in density(self)
196 n, p, succ, fail = self.n, self.p, self.succ, self.fail
197 return dict((k*succ + (n - k)*fail,
--> 198 binomial(n, k) * p**k * (1 - p)**(n - k)) for k in
range
(0, n + 1))
199
200
TypeError: 'Add' object cannot be interpreted as an integer
Attachments:
bug_report.py 134 bytes
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy-issues.
For more options, visit https://groups.google.com/groups/opt_out.