Reputation: 352
This is the raw code, and I want to plot some probability functions. But it does not work, anyone knows what's going wrong?
Thank you guys!!!
from sympy import *
import numpy as np
from sympy.plotting import plot
init_printing()
def f(x):
return (factorial(365) / factorial(365 - x )).evalf() / (365**x)
display(f(5))
x = symbols('x')
plot(f(x),(x,0,100),ylim=[0,2])
Result I got
0.972864426300206
1 |
|
|
|
|
|
|
|
|
|
0 |-------------------------------------------------------
|
|
|
|
|
|
|
|
|
-1 |_______________________________________________________
0 50 100
Upvotes: 0
Views: 89
Reputation: 19135
With
>>> plot((factorial(365) / factorial(365 - x ))/ (365**x),(x,0,100))
Evaluation with the factorial doesn't seem to work, but using rf
or ff
does:
def f(x):
return (ff(365, x)/(365**x)).n(3)
plot(f(x), (x, 0, 2))
Upvotes: 2