Writing your own is a good way to understand the implementation issues
that we sometimes unthinkingly rely on, but for production code, it's
always a good idea to default to the pre-packaged implementation.

In this case, I think it's the standard issue with Scipy not
understanding Sage types. This problem is described in
http://wiki.sagemath.org/faq#Typeissuesusingscipy.2CcvxoptornumpyfromSage

sage: import scipy.stats as stats
sage: stats.binom.pmf(1,10,.56,0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call
last)
<snip>
TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and
'numpy.bool_'

There are numerous fixes to this problem, one of which is:

sage: stats.binom.pmf(1r,10r,.56r,0r)
0.0034614823012532187

As an alternative, if you plan on doing everything in Scipy/Numpy and
don't mind a fat-fisted approach, you may want to use IPython in Pylab
mode: start Sage with "sage -ipython -pylab" and you don't have to
worry about the preprocessor.

On Jul 3, 3:30 pm, Mikie <thephantom6...@hotmail.com> wrote:
> I am trying to use the binomial pmf function in Scipy.  Forget the
> question I will write my own.
> Thanx
>
> On Jul 3, 9:32 am, William Stein <wst...@gmail.com> wrote:
>
>
>
> > On Fri, Jul 3, 2009 at 5:27 PM, Mikie<thephantom6...@hotmail.com> wrote:
>
> > > What is the syntax to get the binomial function in Scipy to calculate?
> > > I have tried stats.binom.pmf(1,10,.56,0) etc.
> > > Thanks  for the help.
>
> > (1) I don't understand the question.  What does your question mean?
>
> > (2) Possibly you should also ask on the scipy support list, where
> > there are likely to be more scipy experts...
>
> > --
> > William Stein
> > Associate Professor of Mathematics
> > University of Washingtonhttp://wstein.org
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to