On 02/26/2010 04:20 PM, Jose Guzman wrote:
This probably has not much to do with Sage, but I need some help. I am
using the binom package of scipy.stats to solve how many trials (N) I
would need to get 40 or more successes at least in 2% of the times.
Basically what I am doing with sage is:

from scipy.stats import binom
from scipy.stats import fsolve

def mybinom(N):
return 1-binom(N,p).cdf(40)


Here, I get an import error:

sage: from scipy.stats import binom
sage: from scipy.stats import fsolve
Traceback (most recent call last):
...
ImportError: cannot import name fsolve


scipy.stats does not have an fsolve function.

Also, you don't say above what p is, so mybinom doesn't work either.

Could you post a self-contained example that gives the error you get below?



fsolve(mybinomial(N)-0.02, 100)

however this returns an error:

TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and
'numpy.bool_'


is there anything similar to the command FindRoot in mathematica ???

g[N_] := Interpolation[Table
FindRoot[g[x] == 0.02 , n, {x, 100, 101}, MaxIterations -> 1000]


It seems like your mathematica code got cut off in the definition of g.

Sage has a find_root command. See http://www.sagemath.org/doc/reference/sage/numerical/optimize.html#sage.numerical.optimize.find_root

However, I think it depends on the function being continuous. I assume that's why the mathematica code appears to find the root of an interpolated function?


Thanks,

Jason


--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to