How to convert erf to decimal and compute normal distribution

37 views
Skip to first unread message

Areeb Sherjil

unread,
Apr 26, 2021, 12:56:31 PM4/26/21
to sympy
Hi everyone,
I am trying to compute the normal distribution of a function. So I need to integrate from 'a' to 'b' and get a decimal answer that would be the probability. When I integrate I get erf; how do I convert to decimal?Formula.png

This is my code:
import sympy as syms
from sympy import exp,sqrt,pi
a=195
b=205
x= syms.symbols('x')
u=202
rho=4
f=syms.exp((-(x-u)**2)/(2*rho**2))/(rho*syms.sqrt(2*syms.pi)) 
Prob= syms.integrate(f,(x,a,b))
Prob.evalf

Kalevi Suominen

unread,
Apr 27, 2021, 9:10:22 AM4/27/21
to sympy
evalf is a function. You have to give the precision as an argument:

>>> Prob.evalf(4)
0.7333
>>> Prob.evalf(10)
0.7333134908

Kalevi Suominen

Areeb Sherjil

unread,
Apr 27, 2021, 9:22:07 AM4/27/21
to sympy
Thanks Kalevi,
Its sorted now

Reply all
Reply to author
Forward
0 new messages