Dallas, Texas United States Member #4549 May 2, 2004 1875 Posts Offline

Posted: April 21, 2011, 9:40 pm - IP Logged

Quote: Originally posted by jimmy4164 on April 21, 2011

Since Basic is the most mentioned computer language here, I adapted the Roulette Simulation from TASC magazine to simulate a Pick3 Game. You should be able to use the source code below to experiment with other simulations. The code is simple because it merely outputs one number for each Trial (Person), leaving the graphics, if wanted, to Excel, or any other program you might prefer. I loaded it into Excel and produced a Histogram similar to those I scanned from the magazine above. The first picture is a pure bar chart based on the frequencies of Equity segments in the data.

If you're smiling at the crudeness and lack of good formatting and labels in this chart, then you are one of the people I'm hoping will give us some tips on how to better utilize Excel for charting!

This second graph is a screen capture describing the same data, but is using mean and standard calculations of the descriptive statistics module I have installed im my Excel. It's called Analyze-It. I've been told that newer versions of Excel can accomplish a lot of what it does, so this is just FWIW.

In this run, among other things, I found the following:

Of the 50,000 "People" who played for 13.7 years...

1012 Broke even (Ended up with their original $5000)

539 were ahead $500

240 were ahead $1000

37 were ahead $1500

6 were ahead $2000

4 were ahead $2500

I'll leave it up to you to calculate the fate of the rest!

The source code below tells you what this data means.

I don't have time now to discuss this, so I'll leave it for you to mull over for a while. What I'm hoping you will eventually be convinced that fair and purely random lotteries can result in people winning far above average expectations, even in Pick3s, WITH NO MORE THAN CHANCE to assist them!

Here's a link to the output of a run of the program below:

Here's the source code of the Basic code. Basic is not my "Native" language, so please check it carefully.

' ' Simulation of a Pick-3 Lottery Game ' ' Adapted by Jimmy4164 from Phil Abel's ' Roulette Simulation in Casino Trading, ' TASC Magazine, November, 2003 ' ' Assumes that 50,000 People each buy one $1 Straight ' ticket per day for 5000 Days, or about 13.7 Years. ' A Win pays $500.

DIM Equity AS LONG DIM Person AS LONG DIM DDraw AS INTEGER DIM LP AS INTEGER ' Lottery's Pick DIM QP AS INTEGER ' Player's QP

' Print results to an Excel file for further analysis

OPEN "PICK3.CSV" FOR OUTPUT AS #3

PRINT #3, "Equity"

RANDOMIZE 11 ' Try different seeds and observe results

' Write each Person's Equity to the file PRINT #3, Equity ' $5000 - Costs + Winnings

IF Person MOD 500 = 0 THEN PRINT Person, Equity, QP, LP 'Halo?

NEXT Person

CLOSE #3 ' Close the file

END

Jimbooble!!!!!

VERY nice! No kidding. Haven't played with it yet, but I will.

Don't know what version of Excel you have, but 2007, (under Insert) there are plenty of options to make chart, line, bar, pie, area, column......don't use them much myself.

Nice explanation of what does what too!

Thanks for sharing it. Now I'll give this post 5 . (Sorry for the 4. My thumbulator is pushing the thingabob on the widget too fast. Did I mention I hate Vista?)

Dallas, Texas United States Member #4549 May 2, 2004 1875 Posts Offline

Posted: April 22, 2011, 6:23 am - IP Logged

Jimbooble!!!!

Had fun playing with the code. Thanks for posting it!!!

My complaints: NONE OF THIS IS YOUR FAULT!!

1) The output screen is lacking any explanantion. It shows the number of draws, theendingbalance (Equity after the 5000 draws), and then it showsthe last QP number and last lottery draw.There were 4999 other draws not shown! Can't figure why that was done.

2) It would have been much more realistic to dimension 50,000 (or at least 100 people with one QP each) for each LP of the 5000 draws.

3) These 50,000 people are not all playing the same game! The way the program is written it runs 5000 draws for person one, then 5000 draws for person 2, 5000 more for person 3, all the way to 50,000.

4) Each of these 50,000 people are playing $1 a night on one QP. (I know that's picky, but even I, the guy who plays out of a change spittoon, have never l played less than $1.50 and three numbers).

I made some changes in the program so that everyone could see what was actually happening. Here's the program with the changes:

' Simulation of a Pick-3 Lottery Game ' Adapted by garyo1954 from Jimmy4164's adaptation from Phil Abel's ' Roulette Simulation in Casino Trading, ' TASC Magazine, November, 2003 ' Assumes that 50,000 People each buy one $1 Straight (for different games) ' ticket per day for 5000 DIFFERENT Days, or about A DIFFERENT 13.7 Years. ' A Win pays $500. VERY IMPORTANT: These people are not playing the same game at the same time!!!!!

DIM Equity AS LONG DIM Person AS LONG DIM DDRAW AS INTEGER DIM LP AS INTEGER ' Lottery's Pick DIM QP AS INTEGER ' Player's QP

' Print results to an Excel file for further analysis OPEN "H:\QB64\PICK3\DATA\MCSIM3.CSV" FOR OUTPUT AS #3 PRINT #3, "Equity"

RANDOMIZE TIMER ' Try different seeds and observe results (changed to use TIMER) FOR Person = 1 TO 50000 'starts 50,000 repetitions of 5000 draws (outside loop) Equity = 5000 ' $5000 Starting Equity (YOUR $$$$$) FOR DDRAW = 1 TO 5000 '(starts 5000 draw cycle; nested loop/inside loop) ' Buy a Ticket (one person, one number, each draw) QP = 10 * INT(RND * 100) + INT(RND * 10) ' Pay the Clerk! (He wants your $1) Equity = Equity - 1 ' Let the Balls Fly! (draw here) LP = 10 * INT(RND * 100) + INT(RND * 10)

IF QP = LP THEN Equity = Equity + 500

' New lines for output screen here:

IF QP = LP THEN Match = Match + 1 'added to count WINS PRINT "Person"; Person; SPC(2); "Draw"; DDRAW; SPC(2); "Equity-1"; Equity; SPC(2); "QP"; QP; SPC(2); "LP"; LP; SPC(2); "Win"; Match 'shows the result of each draw FOR J = 1 TO 50000: NEXT J 'slows output screen; add 0's to slow it more, delete 0's to speed it up, or delete whole line.

NEXT DDRAW '(sends program back to FOR DDRAW for next draw; nested loop/inside loop) ' Write each Person's Equity to the file PRINT #3, Person, Equity, Match ' $5000 - Costs + Winnings (added Person number and Match to file) IF Person MOD 500 = 0 THEN PRINT Person, Equity, QP, LP 'Halo? (?!? Don't know. Would make more sense IF Equity = 0 THEN PRINT Person, Equity, QP, LP) Match = 0 NEXT Person '(send program back to FOR Person to start another 5000 draws for next player; end of outside loop) CLOSE #3 ' Close the file END

It's a nice simulation as long as everyone understands this is not 50,000 people playing $1 each draw on the same game. This is 50,000 people playing $1 a draw on different games or different draws.

BTW, 10 wins break even! Anybody playing a single $1 a draw would have to be VERY lucky with QPs to do that.

MY compliments for posting it Jimbooble!!!!May work on the output file part, REVISED SCREEN LOOKS LIKE:

United States Member #59354 March 13, 2008 4301 Posts Offline

Posted: April 23, 2011, 6:17 am - IP Logged

Quote: Originally posted by jimmy4164 on April 21, 2011

Since Basic is the most mentioned computer language here, I adapted the Roulette Simulation from TASC magazine to simulate a Pick3 Game. You should be able to use the source code below to experiment with other simulations. The code is simple because it merely outputs one number for each Trial (Person), leaving the graphics, if wanted, to Excel, or any other program you might prefer. I loaded it into Excel and produced a Histogram similar to those I scanned from the magazine above. The first picture is a pure bar chart based on the frequencies of Equity segments in the data.

If you're smiling at the crudeness and lack of good formatting and labels in this chart, then you are one of the people I'm hoping will give us some tips on how to better utilize Excel for charting!

This second graph is a screen capture describing the same data, but is using mean and standard calculations of the descriptive statistics module I have installed im my Excel. It's called Analyze-It. I've been told that newer versions of Excel can accomplish a lot of what it does, so this is just FWIW.

In this run, among other things, I found the following:

Of the 50,000 "People" who played for 13.7 years...

1012 Broke even (Ended up with their original $5000)

539 were ahead $500

240 were ahead $1000

37 were ahead $1500

6 were ahead $2000

4 were ahead $2500

I'll leave it up to you to calculate the fate of the rest!

The source code below tells you what this data means.

I don't have time now to discuss this, so I'll leave it for you to mull over for a while. What I'm hoping you will eventually be convinced that fair and purely random lotteries can result in people winning far above average expectations, even in Pick3s, WITH NO MORE THAN CHANCE to assist them!

Here's a link to the output of a run of the program below:

Here's the source code of the Basic code. Basic is not my "Native" language, so please check it carefully.

' ' Simulation of a Pick-3 Lottery Game ' ' Adapted by Jimmy4164 from Phil Abel's ' Roulette Simulation in Casino Trading, ' TASC Magazine, November, 2003 ' ' Assumes that 50,000 People each buy one $1 Straight ' ticket per day for 5000 Days, or about 13.7 Years. ' A Win pays $500.

DIM Equity AS LONG DIM Person AS LONG DIM DDraw AS INTEGER DIM LP AS INTEGER ' Lottery's Pick DIM QP AS INTEGER ' Player's QP

' Print results to an Excel file for further analysis

OPEN "PICK3.CSV" FOR OUTPUT AS #3

PRINT #3, "Equity"

RANDOMIZE 11 ' Try different seeds and observe results

United States Member #93947 July 10, 2010 2180 Posts Offline

Posted: May 9, 2011, 1:45 am - IP Logged

I made a small modification to the Pick-3 simulation code [posted earlier in this thread] to produce output that should be more familiar to most people here. Rather than output the Equity remaining from $5000 after 5000 $1 bets, I converted to Prize Ratio notation. So, a Prize Ratio of 50 corresponds to $2500 Equity remaining in the earlier posting. Here's a screen shot of the transformed results in Excel.

I wrote a throw-away program to compress the 50,000 lines of output from the simulation to produce this frequency chart, and in the process discovered an error in my earlier posting. When I said "6 were ahead $2000," I should have said "16 were ahead $2000." This line corresponds to the 140% Prize Ratio in the chart immediately above.

Hopefully, seeing the results displayed in this way will demonstrate more seamlessly what is going on in this random process, including the breadth of outcomes that are possible. For example, we usually make casual references to the fact that in Pick-3 games, the average prize ratio is expected to be 50%. However, as you can see, in this simulation of 50,000 people making 5000 bets each, only 8,872 actually got this 50% score. Note also that because the lottery payouts are so low, a 100% Prize Ratio is required to break even, moneywise. I'll leave it to you to look over the rest of the entries above, and draw further conclusions. What I hope you are beginning to see is that randomness can result in big losers AND big winners! And this is all possible with, or without, a system...

There have been complaints that my code is not valid because it doesn't pit the 50,000 people against the same lottery draw, but rather gives each person their own draw for each bet. The program is simpler the way it is, and I think you will eventually see that the results will be the same either way, but we can do it the other, just for fun! I think JADELOTTERY's(1) simulation and proof in the 10 ticket/1 draw vs 1 ticket/10 draw Thread should preclude the need for another Pick-3 run, but WHY NOT?!

I would like to be including the revised source code here, but because of what happened when I posted the original, I need more time to figure out how to get the code to people seriously interested without having it torn apart and changed in dubious ways. I'm trying to write code for this thread that can be understood by non-programmers, so there will be no attempt to use tricky algorithms or output fancy graphics. The core ideas in Monte Carlo simulations are really quite simple. Don't worry; the revised program is nearly identical to the original, and I'll keep it safe until we can determine a safe way to publish it.

So, next up will be a run where each of the 50,000 "People" will bet against 1 Lottery Draw, 5000 times. And if all goes well, we might smoothe out the graphs a little by including the more complex BOX calculations in subsequent runs.

United States Member #93947 July 10, 2010 2180 Posts Offline

Posted: May 12, 2011, 12:40 pm - IP Logged

This is not what I said I would be posting next here. But after considering Stack47's comments in the Poll Thread on this Topic, I think it's more important to continue looking at the effects on the distribution of winnings when the number of trials is increased or decreased. Besides, if JADELOTTERY's simulation of One Ticket / Ten Draws vs Ten Tickets / One Draw does not convince you that the way we stage the draw / people loops here is irrelavent, I doubt if I'll change your mind. But time permitting, we WILL try to do it eventually.

Stack47 is interested in 100 Draws, but first, let's go the other way. This graph depicts the frequency distribution of the Prize Ratios resulting from quadrupling the number of draws for each of the 50,000 players from 5,000 to 20,000. Other than this change, the code is identical.

Here is the Excel data compressed from the 50,000 Prize Ratios output from the Basic program:

United States Member #59354 March 13, 2008 4301 Posts Offline

Posted: May 12, 2011, 3:11 pm - IP Logged

Quote: Originally posted by jimmy4164 on May 12, 2011

This is not what I said I would be posting next here. But after considering Stack47's comments in the Poll Thread on this Topic, I think it's more important to continue looking at the effects on the distribution of winnings when the number of trials is increased or decreased. Besides, if JADELOTTERY's simulation of One Ticket / Ten Draws vs Ten Tickets / One Draw does not convince you that the way we stage the draw / people loops here is irrelavent, I doubt if I'll change your mind. But time permitting, we WILL try to do it eventually.

Stack47 is interested in 100 Draws, but first, let's go the other way. This graph depicts the frequency distribution of the Prize Ratios resulting from quadrupling the number of draws for each of the 50,000 players from 5,000 to 20,000. Other than this change, the code is identical.

Here is the Excel data compressed from the 50,000 Prize Ratios output from the Basic program:

United States Member #93947 July 10, 2010 2180 Posts Offline

Posted: May 12, 2011, 8:22 pm - IP Logged

RL-RANDOMLOGIC,

What's under discussion here at the moment is the shape of the curve of the distribution of QuickPick winnings in a Pick3 game. You're rambling here has very little if anything to do with that. You said, "Try as I might I cannot see the point of what you are doing here." You then proceed to completely ignore the data and graph and make no attempt to answer even one of the questions asked. When your belief is that "Backtesting the lottery is also worthless...,"

...why are you posting in a Thread designed for people with an interest in Monte Carlo Techniques and Backtesting?

--Jimmy4164

P.S. You must notice that I have nothing to say in the threads in which you are currently active because I have nothing supportive to say. I would appreciate the same courtesy from you.

United States Member #59354 March 13, 2008 4301 Posts Offline

Posted: May 13, 2011, 12:43 pm - IP Logged

Quote: Originally posted by jimmy4164 on May 12, 2011

RL-RANDOMLOGIC,

What's under discussion here at the moment is the shape of the curve of the distribution of QuickPick winnings in a Pick3 game. You're rambling here has very little if anything to do with that. You said, "Try as I might I cannot see the point of what you are doing here." You then proceed to completely ignore the data and graph and make no attempt to answer even one of the questions asked. When your belief is that "Backtesting the lottery is also worthless...,"

...why are you posting in a Thread designed for people with an interest in Monte Carlo Techniques and Backtesting?

--Jimmy4164

P.S. You must notice that I have nothing to say in the threads in which you are currently active because I have nothing supportive to say. I would appreciate the same courtesy from you.

Jimmy

I thought this post was about Backtesting and Simulating Lottery Systems but I will refrane from posting

Kentucky United States Member #32652 February 14, 2006 7483 Posts Offline

Posted: May 13, 2011, 3:34 pm - IP Logged

Quote: Originally posted by jimmy4164 on May 12, 2011

This is not what I said I would be posting next here. But after considering Stack47's comments in the Poll Thread on this Topic, I think it's more important to continue looking at the effects on the distribution of winnings when the number of trials is increased or decreased. Besides, if JADELOTTERY's simulation of One Ticket / Ten Draws vs Ten Tickets / One Draw does not convince you that the way we stage the draw / people loops here is irrelavent, I doubt if I'll change your mind. But time permitting, we WILL try to do it eventually.

Stack47 is interested in 100 Draws, but first, let's go the other way. This graph depicts the frequency distribution of the Prize Ratios resulting from quadrupling the number of draws for each of the 50,000 players from 5,000 to 20,000. Other than this change, the code is identical.

Here is the Excel data compressed from the 50,000 Prize Ratios output from the Basic program:

Now, compare the graph and the frequency counts to their counterparts above in the last Post with 5000 Draws:

What do you see as the primary difference?

What happened to the 445 people who went completely bust in 5000 Draws?

What happened to the 4 people who scored a 150% PR in 5000 Draws?

What do you see happening to the shape of the curve in the graph as Draws are increased?

Did anyone come out ahead in $ winnings in 20,000 Draws?

--Jimmy4164

If I recall correctly your 33 and 1/2 years PA evening pick-3 analysis showed playing the most frequently drawn number in every drawing would result in a loss so there is really nothing to learn by extending it to 54 years.

"Did anyone come out ahead in $ winnings in 20,000 Draws?"

This question alone is why I believe the test should be more realistic pick-3 play. Considering the fact a player age 18 would be 72 at the end of the test, this questions should be "Will anyone still be alive after 20,000 draws?".

That being said, it does show what QP players should except by continuous play so I guess the next question is "can a system do better in a more reasonable number of drawings?". The old system I suggested is intended for box play using 3 different digits so to test it against say 1000 random ten box combo wagers for 100 drawings, the code would need changing to reflect the probable 28 drawings where some of the 1000 random wagers will collect double winnings.

Hopefully someone else has a straight system you can use for a test.

United States Member #93947 July 10, 2010 2180 Posts Offline

Posted: May 17, 2011, 12:48 am - IP Logged

I think you're confused RL. Your response appears to be to truecritic's misguided comment on my Blog post which dealt with Stephen Hawking's religious beliefs. My Blog entry is on Isaac Asimov's take on American science education...