Trying to solve a problem about Dungeons and Dragons dice rolls. Anyway, I came up with this equation from the following site https://www.desmos.com/calculator/6kylcryv0m :
where
d = 12
m = 10.5
q = 5
Really new with python and statistics and i just need help on how to convert this step by step to python code so i could study it in chunks.
Here we go, this will work. You will need to install scipy and numpy if you haven't already.
from numpy import sqrt, sin, cos, pi, exp
from scipy.integrate import quad
def integrand(x,m,q,s):
return ((1)/(s*sqrt(2*pi))) * exp(-(x-m-q)**2/(2*s**2))
d = 12
m = 10.5
q = 5
s = 5.78
I = quad(integrand, d, 1000, args=(m,q,s))
print(I[0])
Reference page: https://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html
You can ask me any questions about anything that doesn't make sense.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.