The bell shaped Gaussian function,
f(x)=(1/s * root(2*pi)) * exp[(-1/2) * (x-m/s)^2]
is one of the most widely used functions in science and technology.
The parameters m and s > 0 are prescribed real numbers. Make a
program for evaluating this function for different values of s, x and m.
Ask the user to input the values
import math
s=float(input("Enter the value of s "))
x=float(input("Enter the value of x "))
m=float(input("Enter the value of m "))
if(m<0 and s<0):
print("** Invalid Input **")
else:
f1=1/(s*math.sqrt((2*3.14)))
f2=math.exp((-1/2)*(pow(((x-m)/s),2)))
f=f1*f2
print("Answer ",f)
- OutPut
Enter the value of s 3 Enter the value of x 4 Enter the value of m 5 Answer 0.1258263075620745