#OK to post #Ariana Yousafzai, 10/18/2020, Assignment 12 #CPg(L): Givena list of lists L=[L1,L2, ...,Lk] of "databases" (represented as lists L1, L2, ..., Lk) #and outputs CP(L1,L2, ..., Lk) 1. CPg:=proc(L) local i,j,L: L:=[L1,L2, ...,Lk]: for i from 1 to nops(L1) do for j from 1 to nops(Lk) do L:=[op(L),L1[i]+...+Lk[j]]: od: od: L: end: 2. AveGF:=proc(f,x) local f,x: f:=WtEn(f,x): subs(x=1,diff(f,x))/subs(x=1,f): End: #kthMomentGF(f,x,k): The k-th moment about the mean of the population L kthMomentClever:=proc(f,x,k) local x,mu,f,f1,i: f:=WtEn(f,x): mu:=AveClever(f,x,k): f1:=f/x^mu/subs(x=1,f): for i from 1 to k do f1:=expand(x*diff(f1,x)): od: subs(x=1,f1): End: