SM-5-Exercise5

4142 days ago by dmanna

#Strodt number generating function and #Strodt numbers for m-pt distribution t=var('t') def mptStGF(m,t): Q=0 for j in range(m): Q=Q+exp(j*t/(m-1)) return 1/Q def mptP(m,n): g=taylor(mptStGF(m,t),t,0,n) out=g.coefficient(t^n)*factorial(n) if n==0: out=1 return out 
       
#Strodt numbers for 3-pt distribution---What are the patterns? for n in range(10): mptP(3,n) 
       
1
-1/6
1/36
1/24
-1/48
-13/288
7/192
41/384
-809/6912
-671/1536
1
-1/6
1/36
1/24
-1/48
-13/288
7/192
41/384
-809/6912
-671/1536
#Strodt number generating function and #Strodt numbers for general finite distribution t=var('t') def FiniteStGF(p,w,t): Q=0 L=len(p) for j in range(L): Q=Q+exp(p[j]*t)*w[j] return 1/Q def FiniteP(p,w,n): g=taylor(FiniteStGF(p,w,t),t,0,n)*factorial(n) out=g.coefficient(t^n) if n==0: out=1 return out 
       
#Strodt numbers for a certain symmetric distribution for n in range(10): FiniteP([0,1/2,1],[1/4,1/2,1/4],n) 
       
1
-1/2
1/8
1/16
-1/16
-1/32
17/256
17/512
-31/256
-31/512
1
-1/2
1/8
1/16
-1/16
-1/32
17/256
17/512
-31/256
-31/512
#Strodt number generating function and #Strodt numbers for general continuous distribution t=var('t') def CtsStGF(f,a,b,t): Q=integral(f*exp(x*t),(x,a,b)) return 1/Q def CtsP(f,a,b,n): g=taylor(CtsStGF(f,a,b,t),t,0,n) out=g.coefficient(t^n)*factorial(n) if n==0: out=1 return out 
       
#List of Strodt numbers for gaussian distribution (Hermite const. terms) f=exp(-x^2)/sqrt(pi) for n in range(10): CtsP(f,-oo,oo,n) 
       
1
0
-1/2
0
3/4
0
-15/8
0
105/16
0
1
0
-1/2
0
3/4
0
-15/8
0
105/16
0