Message Boards Message Boards

0
|
6225 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Hold[....] is not a number - what does that mean??

Posted 11 years ago

Hello,

my code is the following. It is an algorithm to calculate some Claim distributions...

B := Array[a, {8, 8}]
J := Dimensions[B][[1]]
For[k = 1, k < J + 1, k++, For[i = 1, i < J + 1, i++, a[i, k] = 100]]
For[k = 3, k < J + 1, k++, a[1, k] = (k - 2)/10; a[2, k] = "--"; 
 a[k, 2] = "|"; a[k, 1] = (k - 2)]
a[1, 2] := "proba"; a[2, 1] := "claim"; a[1, 1] := "--"; 
a[2, 2] := "amount"; a[4, 4] = 1000; a[6, 4] = 1000; a[8, 4] = 1000;
B // MatrixForm

p[0] = Product[a[1, k]^Sum [a[l, k], {l, 3, J}], {k, 3, J}];
t[0, i_, j_] := 0;

t[k_, i_, j_] := 
 t[k, i, j] = (1 - a[1, j + 2])/
    a[1, j + 2]*(If[k - i < 0, 0, p[k - i]] - 
     If[k - i < 0, 0, t[k - i, i, j]])
p[k_] := p[k] = 
  Sum[Sum[1/k*i*a[i + 2, j + 2]*t[k, i, j], {j, 1, J - 2}], {i, 1, 
    Min[J - 2, k]}]
For[i = 0, i < 2000, i++, Print[N[p[i]], i]]

The last command yields:

NSum::nsnum: "Summand (or its derivative) (i\a[i+2,j+2]\t[1778,i,j])/1778 is not numerical at point j = 1. "

What happened here? If I insert smaller numbers in the array B, it works perfectly. It seems to have problems with larger numbers?
Thank you for your help.
Jotwie

POSTED BY: Jotwie

It runs (Mathematica 10.0.0 Windows 7 64 Bit) as it stands, but results are absurdly tiny

    In[1]:= B:=Array[a,{8,8}]
    J:=Dimensions[B][[1]]
    For[k=1,k<J+1,k++,For[i=1,i<J+1,i++,a[i,k]=100]]
    For[k=3,k<J+1,k++,a[1,k]=(k-2)/10;a[2,k]="--";
    a[k,2]="|";a[k,1]=(k-2)]
    a[1,2]:="proba";a[2,1]:="claim";a[1,1]:="--";
    a[2,2]:="amount";a[4,4]=1000;a[6,4]=1000;a[8,4]=1000;
    B//MatrixForm

    p[0]=Product[a[1,k]^Sum[a[l,k],{l,3,J}],{k,3,J}];
    t[0,i_,j_]:=0;

    t[k_,i_,j_]:=t[k,i,j]=(1-a[1,j+2])/a[1,j+2]*(If[k-i<0,0,p[k-i]]-If[k-i<0,0,t[k-i,i,j]])
    p[k_]:=p[k]=Sum[Sum[1/k*i*a[i+2,j+2]*t[k,i,j],{j,1,J-2}],{i,1,Min[J-2,k]}]
    Out[7]//MatrixForm= (-- proba   1/10  1/5  3/10 2/5 1/2 3/5
    claim   amount    -- --  --   --    -- --
    1   | 100 100 100 100 100 100
    2   | 100 1000    100    100    100    100
    3   | 100 100 100 100 100 100
    4   | 100 1000    100    100    100    100
    5   | 100 100 100 100 100 100
    6   | 100 1000    100    100    100    100

    )

For[i = 0, i < 2000, i++, Print[N[p[i]], " | ", i]]

1.515256485450908*10^-3773 | 0
2.803224498084179*10^-3770 | 1
2.593199426586201*10^-3767 | 2
1.599450725043749*10^-3764 | 3
7.399918568846731*10^-3762 | 4
2.739330206986893*10^-3759 | 5
<snip>
3.029737703319802*10^-2398 | 1994
8.097275169341772*10^-2398 | 1995
2.163559417657008*10^-2397 | 1996
5.779561424297470*10^-2397 | 1997
1.543537324401404*10^-2396 | 1998
4.121313473809303*10^-2396 | 1999

does it run within a freshly evaluated notebook in a freshly started Mathematica session? Then try to evaluate t[1778,i,j] with typical values for i and j to get an idea what happens ...

POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract