q41b3

20 Reputation

4 Badges

12 years, 129 days

MaplePrimes Activity


These are questions asked by q41b3

Could you help me make this code work?

Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/Matrix.mw .
 

Download Matrix.mw

 

restart;
with(LinearAlgebra);
A := 8; B := 5;
q := .4; p := .2; r := 1-p-q;
dimP := A+B+1;
P := Matrix(dimP, dimP, [0$dimP*dimP]);
P[1, 1] := 1; P[1, 2] := 0;
P[dimP, dimP] := 1; P[dimP, dimP-1] := 0;
for i from 2 to dimP-1 do P[i, i-1] := q; P[i, i] := r; P[i, i+1] := p end do;
p0 := Matrix(dimP, 1, [0$dimP]);
p0[A+1, 1] := 1;
pV[0] := p0;
PT := Transpose(P);
for n to 200 do pV[n] := PT . pV[n-1] end do;
map(proc (x) options operator, arrow; evalf(x, 3) end proc, Transpose(pV[5]));

 

Could you help me fix this code?
Thanks in advance

with(Statistics)

Wpath := proc (steps, t) local walk, i, N, ww; N := nops(steps); walk[0] := 0; for i from 0 to N-1 do walk[i+1] := walk[i]+steps[i+1]*sqrt(t/N) end do; ww := seq(plot(walk[i], t*i/N .. t*(i+1)/N), i = 0 .. N-1); plots[display]([ww]) end proc

N := 400

numbers := [random[empirical[.5, .5]](N)]

st1 := map(proc (x) options operator, arrow; 2*x-3 end proc, numbers)

list_of_k := [40, 20, 10, 5, 2, 1]

for j to nops(list_of_k) do k := list_of_k[j]; st[k] := [seq((sum(st1[p], p = i*k-k+1 .. k*i))/sqrt(k), i = 1 .. N/k)] end do

Error, (in limit/mrv/limsimpl) too many levels of recursion

 

``


 

Download Wiener_process.mw

Could you help me converting this old version code to modern version code(Maple 2017)?
 

restart

N := 2; A := -N; B := N

q := .3; p := .5; sa := .9; sb := .1; r := 1-p-q

dimP := 2*N+1

P := Matrix(dimP, dimP)

P[1, 1] := sa; P[1, 2] := 1-sa; P[dimP, dimP] := sb; P[dimP, dimP-1] := 1-sb

for i from 2 to dimP-1 do P[i, i-1] := q; P[i, i] := r; P[i, i+1] := p end do

P

Matrix(%id = 18446745940352174910)

(1)

# change this part code to the modernversion with(linalg)

J := diag(`$`(1, dimP))

d := matrix(dimP, 1, [`$`(1, dimP)])

b := matrix(dimP+1, 1, [`$`(0, dimP), 1])

A := transpose(augment(P-J, d))

linsolve(A, b)

linsolve(transpose(augment(Matrix(%id = 18446745940387027294), d)), b)

(2)

``


 

Download mdernVersion.mw


 

restart

with(Statistics)

seq(sum((binomial(2*k, k)/4^k)^d, k = 1 .. infinity), d = [3, 4, 5, 6])

MeijerG([[1], [2, 2, 2]], [[3/2, 3/2, 3/2, 1], []], -1)/Pi^(3/2), MeijerG([[1], [2, 2, 2, 2]], [[3/2, 3/2, 3/2, 3/2, 1], []], -1)/Pi^2, MeijerG([[1], [2, 2, 2, 2, 2]], [[3/2, 3/2, 3/2, 3/2, 3/2, 1], []], -1)/Pi^(5/2), MeijerG([[1], [2, 2, 2, 2, 2, 2]], [[3/2, 3/2, 3/2, 3/2, 3/2, 3/2, 1], []], -1)/Pi^3

(1)

``

``


 

Download sum(binomial_with_higer_dim).mw

 The result does not seem to terminate whem I use evalf([%]).  The result should be like this:

(1/8)hypergeom([1,3/2,3/2,3/2],[2,2,2],1), (1/16)hypergeom([1,3/2,3/2,3/2,3/2],[2,2,2,2],1),(1/32)hypergeom([1,3/2,3/2,3/2,3/2,3/2],[2,2,2,2,2],1), (1/64)hypergeom([1,3/2,3/2,3/2,3/2,3/2,3/2],[2,2,2,2,2,2],1)

Thanks in advance.

 

 

The code is from the book(SDE). I think P.n := evalm( P.(n-1)&*P0) causes the problem. I have never seen this kind of the structure before ( I did some coding with C and Java). Could you explain that? P0, P1, P2,,,, using for n from 1 to 10. Is "." between P and n the dot (period)? Thank you in advance.

restart

N := 2; A := -N; B := N

q := .3; p := .5; sa := .9; sb := .1; r := 1-p-q

with(linalg)

dimP := 2*N+1

P := matrix(dimP, dimP, [`$`(0, dimP*dimP)])

P[1, 1] := sa; P[1, 2] := 1-sa; P[dimP, dimP] := sb; P[dimP, dimP-1] := 1-sb

for i from 2 to dimP-1 do P[i, i-1] := q; P[i, i] := r; P[i, i+1] := p end do

P0 := P

for n to 10 do P.n := evalm(`&*`(P.(n-1), P0)) end do

print(P10)

P10

(1)

``


 

Download TransitionMatix.mw

1 2 Page 1 of 2