/3/22 13:50:47 In[54]:=
Clear[f,g,b,A,B,q,,Obs,freq,listPMF,logPMF,LLFunc]
I have this recurrence formula, , where . Assume that the probability model is correct.This formula applied to calculate the maximum log-likelihood value. The problem is that the expression grows massive. Despite running my machine for several days, the computation are went into an infinite amount of period, and I had to kill the kernel multiple times.
f(0)=,f(x)=(j+1)b(j+1)f(x-1-j)
-m
m
x
x-1
∑
j=0
b(j)=A-B,A>0,B>0,>0,0<q<1
j-1
(j-1)!
j
q
j
Data: observed random variable (Obs) and observed frequency (freq)
Data: observed random variable (Obs) and observed frequency (freq)
Obs={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,46,48,51,74};
freq={39,8,12,11,10,6,7,14,21,17,21,15,15,20,27,28,15,14,21,19,22,19,21,18,19,17,14,21,15,12,11,17,14,14,12,15,5,7,4,2,6,2,2,2,1,2,1,2,1};
Method1 to generate list log-likelihood function
Method1 to generate list log-likelihood function
Block{b,x,j,A,B,,q},b[j_]:=b[j]=A-B;g=Table[b[j],{j,1,76}];listPMF={Exp[m]};TablelistPMF=listPMF,Sum[(j+1)g[[j+1]]listPMF[[x-j]],{j,0,x-1}]//Flatten,{x,75}//Last;
j-1
(j-1)!
j
q
j
m
x
Remark: Too slow. Aborted! :(
Method2 to generate list log-likelihood function
Method2 to generate list log-likelihood function
Block{b,x,j,A,B,,q},b[j_]:=b[j]=A-B;g=Table[b[j],{j,1,76}];listPMF={Exp[m]};TablelistPMF=HoldComplete@@AppendTolistPMF,Sum[(j+1)g[[j+1]]listPMF[[x-j]],{j,0,x-1}],{x,75}//Last;
j-1
(j-1)!
j
q
j
m
x
Remark :
1. Using HoldComplete make it appears to have generated the list faster .
2. It is taking again an indefinite amount of time to access the list elements, if number >= 20, for the computation .
3. Finally, I has only to put an end to the kernel :(
1. Using HoldComplete make it appears to have generated the list faster .
2. It is taking again an indefinite amount of time to access the list elements, if number >= 20, for the computation .
3. Finally, I has only to put an end to the kernel :(
Method3 to generate list for log-likelihood function
Method3 to generate list for log-likelihood function
Block{b,x,j,A,B,,q},b[j_]:=b[j]=A-B;f[0]:=Exp[m];f[x_]:=f[x]=Sum[(j+1)b[j+1]f[x-1-j],{j,0,x-1}]
j-1
(j-1)!
j
q
j
m
x
Monitor[listPMF=Table[f[x],{x,Obs}],Grid[{{Text[Style["Generating PMF:",Darker[Blue,0.66]]],ProgressIndicator[x,{1,75}]},{Text[Style["Observed count in process: ",Darker[Blue,0.66]]],x}},Alignment->Left,Dividers->Center]];
Remark: It appears to be executed more quickly, which could be due to the semicolon (;).
Otherwise,it simply hung up for an unknown amount of time. :(
Otherwise,it simply hung up for an unknown amount of time. :(
To build the log-likelihood function
To build the log-likelihood function
logPMF=Map[Log,listPMF];
Remark : I' ve used listPMF variable generate from the method 3 in this case.
/3/22 12:03:27 In[20]:=
Shallow[logPMF]
/3/22 12:03:27 Out[20]//Shallow=
{Log[Power[2]],Log[Times[3]],Log[Times[3]],Log[Times[3]],Log[Times[3]],Log[Times[3]],Log[Times[3]],Log[Times[3]],Log[Times[3]],Log[Times[3]],39}
LLFunc=Apply[Plus,freqlogPMF];(*Objectivefunction*)
/3/22 13:33:10 In[48]:=
Shallow[LLFunc]
/3/22 13:33:10 Out[48]//Shallow=
39Log[1]+12Log[1]+11Log[1]+10Log[1]+6Log[1]+7Log[1]+14Log[1]+21Log[1]+17Log[1]+21Log[1]+39
Overall purpose: For computing the log-likelihood function value
Overall purpose: For computing the log-likelihood function value
NMaximize[{LLfunc,0.01<m&&0.01<A&&0.01<&&0.01<B&&0.01<q<0.99,Element[{m,A,,B,q},Reals]},{m,A,,B,q},Method{"SimulatedAnnealing","BoltzmannExponent"Function[{i,df,f0},-df/(Exp[i/10])],"InitialPoints"Flatten[Table[{i,j,k,l,m},{i,1.,4.,0.1},{j,4.,6.,0.1},{k,4.,6.5,0.1},{l,5.,7.,0.1},{m,0.9,0.998,0.1}],1],"SearchPoints"50,"PerturbationScale"3}]
Remark : Before I aborted it again, I waited more than 24 hours for a result glance. In all cases i cant access the list elements more than 20.
WolframMark Benchmark Report
WolframMark Benchmark Report
Machine Name: | laptop-if53vd2c |
System: | Microsoft Windows (64-bit) |
Date: | March 3, 2022 |
Wolfram Language Version: | 12.3.1 |
Benchmark Result: | 1.35 |
WolframMark Results
WolframMark Results
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|