[Tutor] How to calculate the cumulative normal distribution

Steven D'Aprano steve at pearwood.info
Wed Sep 30 14:15:22 CEST 2015


On Wed, Sep 30, 2015 at 09:12:20AM +0300, Michel Guirguis wrote:
> Good afternoon,
> 
> How to calculate the cumulative normal distribution function CND in 
> order to use this figure to calculate the call option based on the 
> Black and Scholes model.
> 
> >>> from math import*
> >>> def CND(X):
> 	m = abs(X)
> 	[a1,a2,a3,a4,a5]=(0.31938153,-0.356563782,1.781477937,-1.821255978,1.330274429)
> 	k = 1/(1+0.2316419*m)
> 	CND1 = 1.0-1.0/ sqrt(2*3.1415)* exp(-m*m*0.5)
> 	CND2 =(a1*k + a2*k*k+a3*k*k*k+a4*k*k*k*k+a5*k*k*k*k*k)
> 	CND = CND1*CND2

I haven't checked that algorithm, but you need to return a result, not 
assign to the function name:

        return CND1*CND2



-- 
Steve


More information about the Tutor mailing list