MrMarc

3163 Reputation

18 Badges

17 years, 134 days

MaplePrimes Activity


These are replies submitted by MrMarc

"why not ex := ExpectedValue(Empiricaldata) + 1.96 * StandardDeviation(Empiricaldata);"

well you want to test if the data was drawn from a random distribution.
If ex > threshold then it cant be the case since ex is too large ie it should be zero.

Maybe this work for you:


restart:
with(Statistics):

# Simulated random data with mean =0
R := Sample(RandomVariable(Normal(0, 1)), 100):

# 95% of the area under a normal curve lies within roughly 1.96 standard deviations of the mean
threshold := ExpectedValue(R)+1.96*StandardDeviation(R);

# put your empirical data in A
A := Array([1,1,1,2,4,4,5.5]):
Empiricaldata:= Sample(RandomVariable(EmpiricalDistribution(A)),100);
ex := ExpectedValue(Empiricaldata);

# Significant testing
Significant = is(ex > threshold);

"why not ex := ExpectedValue(Empiricaldata) + 1.96 * StandardDeviation(Empiricaldata);"

well you want to test if the data was drawn from a random distribution.
If ex > threshold then it cant be the case since ex is too large ie it should be zero.

Maybe this work for you:


restart:
with(Statistics):

# Simulated random data with mean =0
R := Sample(RandomVariable(Normal(0, 1)), 100):

# 95% of the area under a normal curve lies within roughly 1.96 standard deviations of the mean
threshold := ExpectedValue(R)+1.96*StandardDeviation(R);

# put your empirical data in A
A := Array([1,1,1,2,4,4,5.5]):
Empiricaldata:= Sample(RandomVariable(EmpiricalDistribution(A)),100);
ex := ExpectedValue(Empiricaldata);

# Significant testing
Significant = is(ex > threshold);

This is the code:

The problem now is that I cant change nsim. If I for example change it to
nsim:=10: I get:

Error, invalid subscript selector

I must say maples debug tools suck. I dont even know from what line the error comes from :-(






restart; with(Statistics); randomize(); with(combinat); with(ListTools); X := proc (w) local p1has, z, p1, p11, p11N, p11NN, p11L, c1, c2, c3; p1 := w; unassign('p1has'); if verify(convert([CA, CK, CQ, CJ], set), convert(p1, set), `subset`) = true or verify(convert([DA, DK, DQ, DJ], set), convert(p1, set), `subset`) = true or verify(convert([HA, HK, HQ, HJ], set), convert(p1, set), `subset`) = true or verify(convert([SA, SK, SQ, SJ], set), convert(p1, set), `subset`) = true then p1has := 10 end if; unassign('c1'); unassign('c2'); unassign('c3'); z := {CA = C14, CJ = C11, CK = C13, CQ = C12, DA = D14, DJ = D11, DK = D13, DQ = D12, HA = H14, HJ = H11, HK = H13, HQ = H12, SA = S14, SJ = S11, SK = K13, SQ = S12}; p11 := subs(z, p1); p11N := [parse(convert(p11[1], string)[2 .. 3]), parse(convert(p11[2], string)[2 .. 3]), parse(convert(p11[3], string)[2 .. 3]), parse(convert(p11[4], string)[2 .. 3]), parse(convert(p11[5], string)[2 .. 3]), parse(convert(p11[6], string)[2 .. 3]), parse(convert(p11[7], string)[2 .. 3])]; p11NN := max(p11N); p11L := [parse(convert(p11[1], string)[1]), parse(convert(p11[3], string)[1]), parse(convert(p11[4], string)[1]), parse(convert(p11[5], string)[1]), parse(convert(p11[6], string)[1]), parse(convert(p11[7], string)[1])]; if 5 <= nops([SearchAll(C, p11L)]) then c1 := [SearchAll(C, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(D, p11L)]) then c1 := [SearchAll(D, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(H, p11L)]) then c1 := [SearchAll(H, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(S, p11L)]) then c1 := [SearchAll(S, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] end if; if assigned(c1) = true then c3 := Occurrences(1, [Occurrences(min(c2)+1, c2), Occurrences(min(c2)+2, c2), Occurrences(min(c2)+3, c2), Occurrences(min(c2)+4, c2)]) end if; if assigned(c1) = true and 4 <= c3 then p1has := 9 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 8 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 and Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 7 end if; if 5 <= max([nops([SearchAll(C, p11L)]), nops([SearchAll(D, p11L)]), nops([SearchAll(H, p11L)]), nops([SearchAll(S, p11L)])]) then p1has := 6 end if; c3 := Occurrences(1, [Occurrences(min(p11N)+1, p11N), Occurrences(min(p11N)+2, p11N), Occurrences(min(p11N)+3, p11N), Occurrences(min(p11N)+4, p11N)]); if 4 <= c3 then p1has := 5 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 then p1has := 4 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 3 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 2 end if; if assigned(p1has) = false then p1has := evalf((1/10)*max(p11N), 4) end if; return [p1has, p11NN] end proc; XX := proc () local rr; if X(p2)[1] < X(p1)[1] then rr := "Player 1 Win" elif X(p1)[1] < X(p2)[1] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p2)[2] < X(p1)[2] then rr := "Player 1 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] < X(p2)[2] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] = X(p2)[2] then rr := "Draw" end if; return rr end proc; nsim := 5; cpu := Array(1 .. nsim, 1 .. 1); for j from 2 to 10 do for i from 2 to 10 do cc[i, j] := 0; Clubs := [CA, CK, CQ, CJ, seq(cat(C, i), i = 2 .. 10)]; Diamonds := [DA, DK, DQ, DJ, seq(cat(D, i), i = 2 .. 10)]; Hearts := [HA, HK, HQ, HJ, seq(cat(H, i), i = 2 .. 10)]; Spades := [SA, SK, SQ, SJ, seq(cat(S, i), i = 2 .. 10)]; Cards := [op(Clubs), op(Diamonds), op(Hearts), op(Spades)]; M := Matrix(52, 52); M(1, () .. ()) := `<,>`(Cards[]); M(() .. (), 1) := `<,>`(Cards[]); Get := [M[i, 1], M[1, j]]; for sim to nsim do p1 := [Get[1]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); p1 := [Get[1], Get[2]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [op(p2), Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); flop := Shuffle(Cards)[1 .. 3]; Cards := subs([seq(t = NULL, `in`(t, flop))], Cards); turn := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, turn))], Cards); river := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, river))], Cards); p1 := [op(p1), op(flop), op(turn), op(river)]; p2 := [op(p2), op(flop), op(turn), op(river)]; cpu[sim, 1] := XX(); if cpu[sim, 1] = "Player 1 Win" then cc[i, j] := cc[i, j]+1 end if end do; A[i, j] := evalf(cc[i, j]/nsim, 2); if i = j then A[i, j] := 0 end if end do end do; AA := Matrix(52, 52, proc (i, j) options operator, arrow; A[i, j] end proc); Clubs := [CA, CK, CQ, CJ, seq(cat(C, i), i = 2 .. 10)]; Diamonds := [DA, DK, DQ, DJ, seq(cat(D, i), i = 2 .. 10)]; Hearts := [HA, HK, HQ, HJ, seq(cat(H, i), i = 2 .. 10)]; Spades := [SA, SK, SQ, SJ, seq(cat(S, i), i = 2 .. 10)]; Cards := [op(Clubs), op(Diamonds), op(Hearts), op(Spades)]; AA[() .. (), 1] := `<,>`(Cards[]); AA[1, () .. ()] := `<,>`(Cards[]); AA




Compare this to:


                                                                 0.39600

Which is working beautifuly.

 

restart; with(Statistics); randomize(); with(combinat); with(ListTools); X := proc (w) local p1has, z, p1, p11, p11N, p11NN, p11L, c1, c2, c3; p1 := w; unassign('p1has'); if verify(convert([CA, CK, CQ, CJ], set), convert(p1, set), `subset`) = true or verify(convert([DA, DK, DQ, DJ], set), convert(p1, set), `subset`) = true or verify(convert([HA, HK, HQ, HJ], set), convert(p1, set), `subset`) = true or verify(convert([SA, SK, SQ, SJ], set), convert(p1, set), `subset`) = true then p1has := 10 end if; unassign('c1'); unassign('c2'); unassign('c3'); z := {CA = C14, CJ = C11, CK = C13, CQ = C12, DA = D14, DJ = D11, DK = D13, DQ = D12, HA = H14, HJ = H11, HK = H13, HQ = H12, SA = S14, SJ = S11, SK = K13, SQ = S12}; p11 := subs(z, p1); p11N := [parse(convert(p11[1], string)[2 .. 3]), parse(convert(p11[2], string)[2 .. 3]), parse(convert(p11[3], string)[2 .. 3]), parse(convert(p11[4], string)[2 .. 3]), parse(convert(p11[5], string)[2 .. 3]), parse(convert(p11[6], string)[2 .. 3]), parse(convert(p11[7], string)[2 .. 3])]; p11NN := max(p11N); p11L := [parse(convert(p11[1], string)[1]), parse(convert(p11[3], string)[1]), parse(convert(p11[4], string)[1]), parse(convert(p11[5], string)[1]), parse(convert(p11[6], string)[1]), parse(convert(p11[7], string)[1])]; if 5 <= nops([SearchAll(C, p11L)]) then c1 := [SearchAll(C, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(D, p11L)]) then c1 := [SearchAll(D, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(H, p11L)]) then c1 := [SearchAll(H, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(S, p11L)]) then c1 := [SearchAll(S, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] end if; if assigned(c1) = true then c3 := Occurrences(1, [Occurrences(min(c2)+1, c2), Occurrences(min(c2)+2, c2), Occurrences(min(c2)+3, c2), Occurrences(min(c2)+4, c2)]) end if; if assigned(c1) = true and 4 <= c3 then p1has := 9 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 8 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 and Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 7 end if; if 5 <= max([nops([SearchAll(C, p11L)]), nops([SearchAll(D, p11L)]), nops([SearchAll(H, p11L)]), nops([SearchAll(S, p11L)])]) then p1has := 6 end if; c3 := Occurrences(1, [Occurrences(min(p11N)+1, p11N), Occurrences(min(p11N)+2, p11N), Occurrences(min(p11N)+3, p11N), Occurrences(min(p11N)+4, p11N)]); if 4 <= c3 then p1has := 5 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 then p1has := 4 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 3 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 2 end if; if assigned(p1has) = false then p1has := evalf((1/10)*max(p11N), 4) end if; return [p1has, p11NN] end proc; XX := proc () local rr; if X(p2)[1] < X(p1)[1] then rr := "Player 1 Win" elif X(p1)[1] < X(p2)[1] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p2)[2] < X(p1)[2] then rr := "Player 1 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] < X(p2)[2] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] = X(p2)[2] then rr := "Draw" end if; return rr end proc; nsim := 500; cc := 0; cpu := Array(1 .. nsim, 1 .. 1); for sim to nsim do Clubs := [CA, CK, CQ, CJ, seq(cat(C, i), i = 2 .. 10)]; Diamonds := [DA, DK, DQ, DJ, seq(cat(D, i), i = 2 .. 10)]; Hearts := [HA, HK, HQ, HJ, seq(cat(H, i), i = 2 .. 10)]; Spades := [SA, SK, SQ, SJ, seq(cat(S, i), i = 2 .. 10)]; Cards := [op(Clubs), op(Diamonds), op(Hearts), op(Spades)]; Get := [CJ, CK]; p1 := [Get[1]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); p1 := [Get[1], Get[2]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [op(p2), Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); flop := Shuffle(Cards)[1 .. 3]; Cards := subs([seq(t = NULL, `in`(t, flop))], Cards); turn := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, turn))], Cards); river := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, river))], Cards); p1 := [op(p1), op(flop), op(turn), op(river)]; p2 := [op(p2), op(flop), op(turn), op(river)]; cpu[sim, 1] := XX(); if cpu[sim, 1] = "Player 1 Win" then cc := cc+1 end if end do; evalf(cc/nsim, 5)

 

LL_61)_Poker.mw

This is the code:

The problem now is that I cant change nsim. If I for example change it to
nsim:=10: I get:

Error, invalid subscript selector

I must say maples debug tools suck. I dont even know from what line the error comes from :-(






restart; with(Statistics); randomize(); with(combinat); with(ListTools); X := proc (w) local p1has, z, p1, p11, p11N, p11NN, p11L, c1, c2, c3; p1 := w; unassign('p1has'); if verify(convert([CA, CK, CQ, CJ], set), convert(p1, set), `subset`) = true or verify(convert([DA, DK, DQ, DJ], set), convert(p1, set), `subset`) = true or verify(convert([HA, HK, HQ, HJ], set), convert(p1, set), `subset`) = true or verify(convert([SA, SK, SQ, SJ], set), convert(p1, set), `subset`) = true then p1has := 10 end if; unassign('c1'); unassign('c2'); unassign('c3'); z := {CA = C14, CJ = C11, CK = C13, CQ = C12, DA = D14, DJ = D11, DK = D13, DQ = D12, HA = H14, HJ = H11, HK = H13, HQ = H12, SA = S14, SJ = S11, SK = K13, SQ = S12}; p11 := subs(z, p1); p11N := [parse(convert(p11[1], string)[2 .. 3]), parse(convert(p11[2], string)[2 .. 3]), parse(convert(p11[3], string)[2 .. 3]), parse(convert(p11[4], string)[2 .. 3]), parse(convert(p11[5], string)[2 .. 3]), parse(convert(p11[6], string)[2 .. 3]), parse(convert(p11[7], string)[2 .. 3])]; p11NN := max(p11N); p11L := [parse(convert(p11[1], string)[1]), parse(convert(p11[3], string)[1]), parse(convert(p11[4], string)[1]), parse(convert(p11[5], string)[1]), parse(convert(p11[6], string)[1]), parse(convert(p11[7], string)[1])]; if 5 <= nops([SearchAll(C, p11L)]) then c1 := [SearchAll(C, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(D, p11L)]) then c1 := [SearchAll(D, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(H, p11L)]) then c1 := [SearchAll(H, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(S, p11L)]) then c1 := [SearchAll(S, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] end if; if assigned(c1) = true then c3 := Occurrences(1, [Occurrences(min(c2)+1, c2), Occurrences(min(c2)+2, c2), Occurrences(min(c2)+3, c2), Occurrences(min(c2)+4, c2)]) end if; if assigned(c1) = true and 4 <= c3 then p1has := 9 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 8 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 and Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 7 end if; if 5 <= max([nops([SearchAll(C, p11L)]), nops([SearchAll(D, p11L)]), nops([SearchAll(H, p11L)]), nops([SearchAll(S, p11L)])]) then p1has := 6 end if; c3 := Occurrences(1, [Occurrences(min(p11N)+1, p11N), Occurrences(min(p11N)+2, p11N), Occurrences(min(p11N)+3, p11N), Occurrences(min(p11N)+4, p11N)]); if 4 <= c3 then p1has := 5 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 then p1has := 4 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 3 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 2 end if; if assigned(p1has) = false then p1has := evalf((1/10)*max(p11N), 4) end if; return [p1has, p11NN] end proc; XX := proc () local rr; if X(p2)[1] < X(p1)[1] then rr := "Player 1 Win" elif X(p1)[1] < X(p2)[1] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p2)[2] < X(p1)[2] then rr := "Player 1 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] < X(p2)[2] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] = X(p2)[2] then rr := "Draw" end if; return rr end proc; nsim := 5; cpu := Array(1 .. nsim, 1 .. 1); for j from 2 to 10 do for i from 2 to 10 do cc[i, j] := 0; Clubs := [CA, CK, CQ, CJ, seq(cat(C, i), i = 2 .. 10)]; Diamonds := [DA, DK, DQ, DJ, seq(cat(D, i), i = 2 .. 10)]; Hearts := [HA, HK, HQ, HJ, seq(cat(H, i), i = 2 .. 10)]; Spades := [SA, SK, SQ, SJ, seq(cat(S, i), i = 2 .. 10)]; Cards := [op(Clubs), op(Diamonds), op(Hearts), op(Spades)]; M := Matrix(52, 52); M(1, () .. ()) := `<,>`(Cards[]); M(() .. (), 1) := `<,>`(Cards[]); Get := [M[i, 1], M[1, j]]; for sim to nsim do p1 := [Get[1]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); p1 := [Get[1], Get[2]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [op(p2), Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); flop := Shuffle(Cards)[1 .. 3]; Cards := subs([seq(t = NULL, `in`(t, flop))], Cards); turn := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, turn))], Cards); river := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, river))], Cards); p1 := [op(p1), op(flop), op(turn), op(river)]; p2 := [op(p2), op(flop), op(turn), op(river)]; cpu[sim, 1] := XX(); if cpu[sim, 1] = "Player 1 Win" then cc[i, j] := cc[i, j]+1 end if end do; A[i, j] := evalf(cc[i, j]/nsim, 2); if i = j then A[i, j] := 0 end if end do end do; AA := Matrix(52, 52, proc (i, j) options operator, arrow; A[i, j] end proc); Clubs := [CA, CK, CQ, CJ, seq(cat(C, i), i = 2 .. 10)]; Diamonds := [DA, DK, DQ, DJ, seq(cat(D, i), i = 2 .. 10)]; Hearts := [HA, HK, HQ, HJ, seq(cat(H, i), i = 2 .. 10)]; Spades := [SA, SK, SQ, SJ, seq(cat(S, i), i = 2 .. 10)]; Cards := [op(Clubs), op(Diamonds), op(Hearts), op(Spades)]; AA[() .. (), 1] := `<,>`(Cards[]); AA[1, () .. ()] := `<,>`(Cards[]); AA




Compare this to:


                                                                 0.39600

Which is working beautifuly.

 

restart; with(Statistics); randomize(); with(combinat); with(ListTools); X := proc (w) local p1has, z, p1, p11, p11N, p11NN, p11L, c1, c2, c3; p1 := w; unassign('p1has'); if verify(convert([CA, CK, CQ, CJ], set), convert(p1, set), `subset`) = true or verify(convert([DA, DK, DQ, DJ], set), convert(p1, set), `subset`) = true or verify(convert([HA, HK, HQ, HJ], set), convert(p1, set), `subset`) = true or verify(convert([SA, SK, SQ, SJ], set), convert(p1, set), `subset`) = true then p1has := 10 end if; unassign('c1'); unassign('c2'); unassign('c3'); z := {CA = C14, CJ = C11, CK = C13, CQ = C12, DA = D14, DJ = D11, DK = D13, DQ = D12, HA = H14, HJ = H11, HK = H13, HQ = H12, SA = S14, SJ = S11, SK = K13, SQ = S12}; p11 := subs(z, p1); p11N := [parse(convert(p11[1], string)[2 .. 3]), parse(convert(p11[2], string)[2 .. 3]), parse(convert(p11[3], string)[2 .. 3]), parse(convert(p11[4], string)[2 .. 3]), parse(convert(p11[5], string)[2 .. 3]), parse(convert(p11[6], string)[2 .. 3]), parse(convert(p11[7], string)[2 .. 3])]; p11NN := max(p11N); p11L := [parse(convert(p11[1], string)[1]), parse(convert(p11[3], string)[1]), parse(convert(p11[4], string)[1]), parse(convert(p11[5], string)[1]), parse(convert(p11[6], string)[1]), parse(convert(p11[7], string)[1])]; if 5 <= nops([SearchAll(C, p11L)]) then c1 := [SearchAll(C, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(D, p11L)]) then c1 := [SearchAll(D, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(H, p11L)]) then c1 := [SearchAll(H, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] elif 5 <= nops([SearchAll(S, p11L)]) then c1 := [SearchAll(S, p11L)]; c2 := [seq(p11N[c1[i]], i = 1 .. nops(c1))] end if; if assigned(c1) = true then c3 := Occurrences(1, [Occurrences(min(c2)+1, c2), Occurrences(min(c2)+2, c2), Occurrences(min(c2)+3, c2), Occurrences(min(c2)+4, c2)]) end if; if assigned(c1) = true and 4 <= c3 then p1has := 9 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 8 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 and Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 7 end if; if 5 <= max([nops([SearchAll(C, p11L)]), nops([SearchAll(D, p11L)]), nops([SearchAll(H, p11L)]), nops([SearchAll(S, p11L)])]) then p1has := 6 end if; c3 := Occurrences(1, [Occurrences(min(p11N)+1, p11N), Occurrences(min(p11N)+2, p11N), Occurrences(min(p11N)+3, p11N), Occurrences(min(p11N)+4, p11N)]); if 4 <= c3 then p1has := 5 end if; if max([seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 3 then p1has := 4 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 4 then p1has := 3 end if; if Occurrences(2, [seq(Occurrences(op(p11N[x]), p11N), x = 1 .. nops(p11N))]) = 2 then p1has := 2 end if; if assigned(p1has) = false then p1has := evalf((1/10)*max(p11N), 4) end if; return [p1has, p11NN] end proc; XX := proc () local rr; if X(p2)[1] < X(p1)[1] then rr := "Player 1 Win" elif X(p1)[1] < X(p2)[1] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p2)[2] < X(p1)[2] then rr := "Player 1 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] < X(p2)[2] then rr := "Player 2 Win" elif X(p1)[1] = X(p2)[1] and X(p1)[2] = X(p2)[2] then rr := "Draw" end if; return rr end proc; nsim := 500; cc := 0; cpu := Array(1 .. nsim, 1 .. 1); for sim to nsim do Clubs := [CA, CK, CQ, CJ, seq(cat(C, i), i = 2 .. 10)]; Diamonds := [DA, DK, DQ, DJ, seq(cat(D, i), i = 2 .. 10)]; Hearts := [HA, HK, HQ, HJ, seq(cat(H, i), i = 2 .. 10)]; Spades := [SA, SK, SQ, SJ, seq(cat(S, i), i = 2 .. 10)]; Cards := [op(Clubs), op(Diamonds), op(Hearts), op(Spades)]; Get := [CJ, CK]; p1 := [Get[1]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); p1 := [Get[1], Get[2]]; Cards := subs([seq(t = NULL, `in`(t, p1))], Cards); p2 := [op(p2), Shuffle(Cards)[1]]; Cards := subs([seq(t = NULL, `in`(t, p2))], Cards); flop := Shuffle(Cards)[1 .. 3]; Cards := subs([seq(t = NULL, `in`(t, flop))], Cards); turn := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, turn))], Cards); river := Shuffle(Cards)[1]; Cards := subs([seq(t = NULL, `in`(t, river))], Cards); p1 := [op(p1), op(flop), op(turn), op(river)]; p2 := [op(p2), op(flop), op(turn), op(river)]; cpu[sim, 1] := XX(); if cpu[sim, 1] = "Player 1 Win" then cc := cc+1 end if end do; evalf(cc/nsim, 5)

 

LL_61)_Poker.mw

If I put:



Then I get:


                       0.80000 = 0.80000
                        1.6000 = 1.6000
                            2. = 2.
                        2.4000 = 2.4000
                        2.6000 = 2.6000
                        2.8000 = 2.8000
                            3. = 3.
                        3.4000 = 3.4000
                        4.2000 = 4.2000
                        4.8000 = 4.8000
                        5.6000 = 5.6000
                            6. = 6.
                        6.4000 = 6.4000

So the matrix get assigned but when you call it like:

M;

It is empty. Very strange...

If I put in



just before the 

end do
end do


Maple prints a bunch of values hence it is working
but they are not stored in the matrix humm...

The last one is wrong I think I have to work on that a little more :-)

could you explain a little more please?! I am not sure I get this?
Is the stock example correct or is it wrong? If it is right it should be the same hummm (2/3)

excellent :-) :-)

I must say that I dont fully understand this problem:
Let say we switches to two stocks with + and - returns.

My portfolio contains 2 stocks. At least one of them has a negative return.
What is the probability that stock 2 has a positive return?

The probability should be 2/3 here as well but I dont understand how
to use that in an application...

However now I have a new problem on my hands. It appears that:

FileTools:-RemoveDirectory("C:\\mydir", recurse = true, forceremove = true)

is not working properly. The folder is never removed hummm

Later comment:

I think I solved that too :-) I had to put it like:

return DL(), FileTools:-RemoveDirectory("C:\\mydir", recurse = true, forceremove = true)

Sweet now everything is working :-) Now you can download from both http and https
as it should be!

However now I have a new problem on my hands. It appears that:

FileTools:-RemoveDirectory("C:\\mydir", recurse = true, forceremove = true)

is not working properly. The folder is never removed hummm

Later comment:

I think I solved that too :-) I had to put it like:

return DL(), FileTools:-RemoveDirectory("C:\\mydir", recurse = true, forceremove = true)

Sweet now everything is working :-) Now you can download from both http and https
as it should be!

@Carl Love I think I solved it :-)
I forgot to put in return hence the procedure did not return anything. Sometimes it works without return but in this case it obviously did not:


X:=proc(Url) local theDLL, URLDownloadToFile,myDirectory,myFile ,Destination, DL;

theDLL := "C:\\WINDOWS\\SYSTEM32\\urlmon.dll":
URLDownloadToFile := define_external('URLDownloadToFileA', pCaller::(integer[4]), szURL::string, szFileName::string, dwReserved::(integer[4]), lpfnCB::(integer[4]), 'RETURN'::(integer[4]), LIB = theDLL):

FileTools:-MakeDirectory("C:\\mydir"):

myDirectory := "C:\\mydir":
myFile := "data1.csv":
Destination := cat(myDirectory, "\\", myFile):

DL := proc()

URLDownloadToFile(0, Url, Destination, 0, 0):
ImportMatrix("C:\\mydir\\data1.csv", source = csv):
end proc:

return DL();
FileTools:-RemoveDirectory("C:\\mydir", recurse = true, forceremove = true):
end proc:

X("https://dl.dropboxusercontent.com/s/khlt43gd7h6u4px/Nasdaq%20%28Percentage%20Change%29.csv?token_hash=AAEXqTpqcaFXTaOxcMaplC_DWoqJcEdkRZK_cFfMvHKEaQ&dl=1")

@Carl Love I think I solved it :-)
I forgot to put in return hence the procedure did not return anything. Sometimes it works without return but in this case it obviously did not:


X:=proc(Url) local theDLL, URLDownloadToFile,myDirectory,myFile ,Destination, DL;

theDLL := "C:\\WINDOWS\\SYSTEM32\\urlmon.dll":
URLDownloadToFile := define_external('URLDownloadToFileA', pCaller::(integer[4]), szURL::string, szFileName::string, dwReserved::(integer[4]), lpfnCB::(integer[4]), 'RETURN'::(integer[4]), LIB = theDLL):

FileTools:-MakeDirectory("C:\\mydir"):

myDirectory := "C:\\mydir":
myFile := "data1.csv":
Destination := cat(myDirectory, "\\", myFile):

DL := proc()

URLDownloadToFile(0, Url, Destination, 0, 0):
ImportMatrix("C:\\mydir\\data1.csv", source = csv):
end proc:

return DL();
FileTools:-RemoveDirectory("C:\\mydir", recurse = true, forceremove = true):
end proc:

X("https://dl.dropboxusercontent.com/s/khlt43gd7h6u4px/Nasdaq%20%28Percentage%20Change%29.csv?token_hash=AAEXqTpqcaFXTaOxcMaplC_DWoqJcEdkRZK_cFfMvHKEaQ&dl=1")

Axel I added some extra bells and whistles to the code such as

FileTools:-MakeDirectory("C:\\mydir")
ImportMatrix("C:\\mydir\\data1.csv", source = csv)
FileTools:-RemoveDirectory("C:\\mydir", recurse = true, forceremove = true)

It works great :-) However I did not manage to make it a procedure.
It would be great if it was possible to make it a procedure so I can put it in a module
instead of having to change the code all the time

Http_and_Https.mw

 

 

2 3 4 5 6 7 8 Last Page 4 of 33