jackace Joined: Nov 23, 2021
• 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:
/games/lottery/powerball-calculator/

The Super Lotto Plus calculator seems incorrect:
/games/lottery/california-super-lotto-plus-calculator/

The Mega Millions calculator seems correct:
/games/lottery/mega-millions-calculator/

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
0.0521867
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_prob_array=yes_combin_array/total_combin;    no_prob_array=no_combin_array/total_combin;    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    tot_ret+=(yes_ret_array+no_ret_array);  }  // code omitted here  s5ret.value=FormatNum(yes_ret_array/cost,6); // dividing by cost again  s4ret.value=FormatNum(yes_ret_array/cost,6); // dividing by cost again  s3ret.value=FormatNum(yes_ret_array/cost,6); // dividing by cost again  s2ret.value=FormatNum(yes_ret_array/cost,6); // dividing by cost again  s1ret.value=FormatNum(yes_ret_array/cost,6); // dividing by cost again  s0ret.value=FormatNum(yes_ret_array/cost,6); // dividing by cost again  5ret.value=FormatNum(no_ret_array/cost,6); // dividing by cost again  4ret.value=FormatNum(no_ret_array/cost,6); // dividing by cost again  3ret.value=FormatNum(no_ret_array/cost,6); // dividing by cost again  2ret.value=FormatNum(no_ret_array/cost,6); // dividing by cost again  1ret.value=FormatNum(no_ret_array/cost,6); // dividing by cost again  0ret.value=FormatNum(no_ret_array/cost,6); // dividing by cost again`
Jack Hayes
Dieter 