Joined: Nov 23, 2021
  • Threads: 1
  • Posts: 7
March 1st, 2023 at 4:08:54 PM permalink
Hey, Wizard!

I'm a mathematician/engineer and I was working on a Lottery Calculator similar to yours and I think I've noticed a bug on your calculator(s). In the Power Ball and the Super Lotto Plus calculators, when you calculate the return, I believe you're dividing by the cost of the ticket twice, resulting in a much lower expected return.

The Power Ball calculator seems incorrect:

The Super Lotto Plus calculator seems incorrect:

The Mega Millions calculator seems correct:

In the PowerBall calculator, if you just run it as is, you get the following stats for 0+Powerball:
Win: $4
Combos: 7,624,512
Ticket Cost: $2
Total Combos: 292,201,338

A quick calculation should get a return of
which is 4*7624512 / (2*292201338)
but you show 0.026093, which is half that.

In the code, it looks like you divide by cost in the for loop and then you divide by cost when you update the UI.

for (i=0; i<=5; i++)
yes_ret_array=(yes_prob_array*yes_win_array)/cost; // dividing by cost here
no_ret_array=(no_prob_array*no_win_array)/cost; // dividing by cost here

// code omitted here

s5ret.value=FormatNum(yes_ret_array[5]/cost,6); // dividing by cost again
s4ret.value=FormatNum(yes_ret_array[4]/cost,6); // dividing by cost again
s3ret.value=FormatNum(yes_ret_array[3]/cost,6); // dividing by cost again
s2ret.value=FormatNum(yes_ret_array[2]/cost,6); // dividing by cost again
s1ret.value=FormatNum(yes_ret_array[1]/cost,6); // dividing by cost again
s0ret.value=FormatNum(yes_ret_array[0]/cost,6); // dividing by cost again
5ret.value=FormatNum(no_ret_array[5]/cost,6); // dividing by cost again
4ret.value=FormatNum(no_ret_array[4]/cost,6); // dividing by cost again
3ret.value=FormatNum(no_ret_array[3]/cost,6); // dividing by cost again
2ret.value=FormatNum(no_ret_array[2]/cost,6); // dividing by cost again
1ret.value=FormatNum(no_ret_array[1]/cost,6); // dividing by cost again
0ret.value=FormatNum(no_ret_array[0]/cost,6); // dividing by cost again
Jack Hayes
Joined: Jul 23, 2014
  • Threads: 13
  • Posts: 4297

  • Jump to: