简体   繁体   English

math-python 将统计方程转换为代码

[英]math-python converting statistics equation to code

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 :无论如何,我从以下站点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. python 和统计数据真的很新,我只需要有关如何将此逐步转换为 python 代码的帮助,以便我可以分块研究它。

Here we go, this will work.在这里我们 go,这将工作。 You will need to install scipy and numpy if you haven't already.如果您还没有安装 scipy 和 numpy,则需要安装。

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参考页: https://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html

You can ask me any questions about anything that doesn't make sense.你可以问我任何关于任何没有意义的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM