wb_jerry

5 Reputation

One Badge

12 years, 129 days

MaplePrimes Activity


These are replies submitted by wb_jerry

Your method works. Thank you so much!

I used to think that I am a qualified maple progammer, but not any more. I think I need to learn more about the internal representation of data in maple. Your erudition and enthusiasm impressed me a lot. Really appreciate it.

Your method works. Thank you so much!

I used to think that I am a qualified maple progammer, but not any more. I think I need to learn more about the internal representation of data in maple. Your erudition and enthusiasm impressed me a lot. Really appreciate it.

Thank you for your reply, Carl.

To calculate the the steady state probibility, the transition matrix must satisfy the condition that  the elements of each row sum to 1, otherwise the equations would be unsolvable. I tried using float datatype but it turned out that the sum of each row would be unequal to 1 because of the approximation error. So I had to use exact rational arithmetic.

I don't know if I made myself clear. If not please let me konw. Thanks again for your attention.

Thank you for your reply, Carl.

To calculate the the steady state probibility, the transition matrix must satisfy the condition that  the elements of each row sum to 1, otherwise the equations would be unsolvable. I tried using float datatype but it turned out that the sum of each row would be unequal to 1 because of the approximation error. So I had to use exact rational arithmetic.

I don't know if I made myself clear. If not please let me konw. Thanks again for your attention.

@Carl Love

Hi, Carl,
Thank you very much for very useful suggestions about solving a large linear system.
Due to my ability, I still could not solve the problem.
I attach my source code. When m=600, the error " maple was unable to allocate enough memory to complete this computation"  is generated after 6 hours.
Could you please tell me what error with mycode and whether there is any improvement about my source code?
In addition, is there any method to speed up the computation? I have tried linearsolve. the computation is even slower.

Lots of thank in advance.
Looking forward to your reply
--Jerry

 

restart; with(combinat)

[Chi, bell, binomial, cartprod, character, choose, composition, conjpart, decodepart, encodepart, eulerian1, eulerian2, fibonacci, firstcomb, firstpart, firstperm, graycode, inttovec, lastcomb, lastpart, lastperm, multinomial, nextcomb, nextpart, nextperm, numbcomb, numbcomp, numbpart, numbperm, partition, permute, powerset, prevcomb, prevpart, prevperm, randcomb, randpart, randperm, rankcomb, rankperm, setpartition, stirling1, stirling2, subsets, unrankcomb, unrankperm, vectoint]

(1)

kernelopts(datalimit = 3000000);

1405760

(2)

CTProb := proc (i::integer, j::integer, m::integer) local p, x, y, w; y := 1/(1+.8*m*1.5^2)^(1/1.5^2); if type(y, rational) = false then y := evalf(y); y := convert(y, rational) end if; x := (1-y)/(.8*m); if type(x, rational) = false then x := evalf(x); x := convert(x, rational) end if; w := i+1-j; if i+1 < j then p := 0 elif i < m and j <= m then p := numbcomb(i, i-j)*x^(i-j)*(1-x)^j*y+numbcomb(i, i+1-j)*x^(i+1-j)*(1-x)^(j-1)*(1-y) elif m <= i and m <= j then p := add(numbcomb(m, s1)*x^s1*(1-x)^(m-s1)*add(numbcomb(s1, s2)*y^s2*(1-y)^(s1-s2)*numbcomb(s2, w-s1-s2)*y^(w-s1-s2)*(1-y)^(2*s2+s1-w), s2 = min(w-s1, 1) .. min(w-s1, s1)), s1 = min(w, 1) .. min(w, m)) elif m <= i and j < m then p := add(numbcomb(m, s1)*x^s1*(1-x)^(m-s1)*add(numbcomb(min(i+1-m, s1), s2)*y^s2*(1-y)^(s1-s2)*numbcomb(min(max(i+1-m-s1, 0), s2), w-s1-s2)*y^(w-s1-s2)*(1-y)^(s2-max(i+1-m-s1-s2, 0)), s2 = min(w-s1, m-j) .. min(w-s1, s1)), s1 = m-j .. min(w, m))/(1-y)^(m-j) end if; return p end proc;

CM := proc (m::integer) local P, i, j, t; P := RandomMatrix(m+2, outputoptions = [datatype = float[8]]); print(

CSProb := proc (m::integer) local P, solutions, phai, l, eqns; P := CM(m); P[m+1, m+1] := P[m+1, m+1]+P[m+1, m+2]; eqns := {`$`('phai[i+1] = add(phai[j+1]*P[j+1, i+1], j = 0 .. m)', i = 0 .. m), add(phai[i+1], i = 0 .. m) = 1}; solutions := solve(eqns, {`$`(phai[j+1], j = 0 .. m)}); assign(solutions) end proc;

(3)

``

 

Download a1.mwa1.mw

@Carl Love

Hi, Carl,
Thank you very much for very useful suggestions about solving a large linear system.
Due to my ability, I still could not solve the problem.
I attach my source code. When m=600, the error " maple was unable to allocate enough memory to complete this computation"  is generated after 6 hours.
Could you please tell me what error with mycode and whether there is any improvement about my source code?
In addition, is there any method to speed up the computation? I have tried linearsolve. the computation is even slower.

Lots of thank in advance.
Looking forward to your reply
--Jerry

 

restart; with(combinat)

[Chi, bell, binomial, cartprod, character, choose, composition, conjpart, decodepart, encodepart, eulerian1, eulerian2, fibonacci, firstcomb, firstpart, firstperm, graycode, inttovec, lastcomb, lastpart, lastperm, multinomial, nextcomb, nextpart, nextperm, numbcomb, numbcomp, numbpart, numbperm, partition, permute, powerset, prevcomb, prevpart, prevperm, randcomb, randpart, randperm, rankcomb, rankperm, setpartition, stirling1, stirling2, subsets, unrankcomb, unrankperm, vectoint]

(1)

kernelopts(datalimit = 3000000);

1405760

(2)

CTProb := proc (i::integer, j::integer, m::integer) local p, x, y, w; y := 1/(1+.8*m*1.5^2)^(1/1.5^2); if type(y, rational) = false then y := evalf(y); y := convert(y, rational) end if; x := (1-y)/(.8*m); if type(x, rational) = false then x := evalf(x); x := convert(x, rational) end if; w := i+1-j; if i+1 < j then p := 0 elif i < m and j <= m then p := numbcomb(i, i-j)*x^(i-j)*(1-x)^j*y+numbcomb(i, i+1-j)*x^(i+1-j)*(1-x)^(j-1)*(1-y) elif m <= i and m <= j then p := add(numbcomb(m, s1)*x^s1*(1-x)^(m-s1)*add(numbcomb(s1, s2)*y^s2*(1-y)^(s1-s2)*numbcomb(s2, w-s1-s2)*y^(w-s1-s2)*(1-y)^(2*s2+s1-w), s2 = min(w-s1, 1) .. min(w-s1, s1)), s1 = min(w, 1) .. min(w, m)) elif m <= i and j < m then p := add(numbcomb(m, s1)*x^s1*(1-x)^(m-s1)*add(numbcomb(min(i+1-m, s1), s2)*y^s2*(1-y)^(s1-s2)*numbcomb(min(max(i+1-m-s1, 0), s2), w-s1-s2)*y^(w-s1-s2)*(1-y)^(s2-max(i+1-m-s1-s2, 0)), s2 = min(w-s1, m-j) .. min(w-s1, s1)), s1 = m-j .. min(w, m))/(1-y)^(m-j) end if; return p end proc;

CM := proc (m::integer) local P, i, j, t; P := RandomMatrix(m+2, outputoptions = [datatype = float[8]]); print(

CSProb := proc (m::integer) local P, solutions, phai, l, eqns; P := CM(m); P[m+1, m+1] := P[m+1, m+1]+P[m+1, m+2]; eqns := {`$`('phai[i+1] = add(phai[j+1]*P[j+1, i+1], j = 0 .. m)', i = 0 .. m), add(phai[i+1], i = 0 .. m) = 1}; solutions := solve(eqns, {`$`(phai[j+1], j = 0 .. m)}); assign(solutions) end proc;

(3)

``

 

Download a1.mwa1.mw

@Carl Love

Floating-point solution is acceptable.

Of course you helped me a lot. Really sorry for the misunderstanding caused by my poor English.

@Carl Love

Floating-point solution is acceptable.

Of course you helped me a lot. Really sorry for the misunderstanding caused by my poor English.

Hi, Carl! Thanks for your help.

I have printed some information as you said and I'm sure the error occur after CalculateMatrix.

I will try to modify my programusing LinearSolve and see if it works. Thanks anyway.

Hi, Carl! Thanks for your help.

I have printed some information as you said and I'm sure the error occur after CalculateMatrix.

I will try to modify my programusing LinearSolve and see if it works. Thanks anyway.

Page 1 of 1