Post Reply 
Powerball Generator!
05-23-2024, 09:42 PM
Post: #1
Powerball Generator!
...who doesn't need a handy Powerball generator every now and then? Tongue

Picks 1st five numbers between 1-69, no-dupes, then picks the lucky Powerball number between 1-26! Uses the Alpha Register to format the output, a 1x6 array, and the fancy [FIND] function to keep duplicates in check!

00 { 127-Byte Prgm }
01 LBL "PBALL"
02 CLA
03 CLD
04 6
05 1
06 DIM "PBALL"
07 INDEX "PBALL"
08 1.00501
09 STO "CNT"
10 LBL 01
11 RCL "CNT"
12 1
13 STOIJ
14 RAN
15 100
16 ×
17 IP
18 STO 10
19 69
20 X<>Y
21 X>Y?
22 GTO 01
23 X≤0?
24 GTO 01
25 [FIND]
26 GTO 01
27 STOEL
28 ├" "
29 AIP
30 ISG "CNT"
31 GTO 01
32 LBL 02
33 6
34 1
35 STOIJ
36 RAN
37 100
38 ×
39 IP
40 STO 10
41 26
42 X<>Y
43 X>Y?
44 GTO 02
45 X≤0?
46 GTO 02
47 STOEL
48 ├" PB: "
49 AIP
50 AVIEW
51 END
Find all posts by this user
Quote this message in a reply
05-24-2024, 12:36 PM
Post: #2
RE: Powerball Generator!
If I run this program and win, do I have to split the winnings? Smile
Find all posts by this user
Quote this message in a reply
05-24-2024, 04:18 PM
Post: #3
RE: Powerball Generator!
Winner's choice! Tongue

(05-24-2024 12:36 PM)carey Wrote:  If I run this program and win, do I have to split the winnings? Smile
Find all posts by this user
Quote this message in a reply
09-13-2024, 04:11 AM
Post: #4
RE: Powerball Generator!
If I run this program will (Underlined), I win?
Fingers Crossed
Find all posts by this user
Quote this message in a reply
09-13-2024, 07:18 AM (This post was last modified: 09-13-2024 10:25 AM by Thomas Klemm.)
Post: #5
RE: Powerball Generator!
A bit shorter:
Code:
00 { 95-Byte Prgm }
01▸LBL "PBALL"
02 CLA
03 6
04 1
05 DIM "PBALL"
06 INDEX "PBALL"
07 1.005
08 STO 00
09▸LBL 01
10 RCL 00
11 1
12 STOIJ
13 69
14 XEQ 00
15 [FIND]
16 GTO 01
17 STOEL
18 ├" "
19 AIP
20 ISG 00
21 GTO 01
22 6
23 1
24 STOIJ
25 26
26 XEQ 00
27 STOEL
28 ├" PB: "
29 AIP
30 AVIEW
31 RTN
32▸LBL 00
33 RAN
34 ×
35 IP
36 1
37 +
38 END

Changes

The subroutine at LBL 00 generates a random number from 1 to X.
This makes the checks at the boundaries unnecessary.
I also use the register 00 instead of the global variable "CNT".
But that's more a matter of taste.
There's no obvious reason to store a result in the register 10 since it's never used.
So I removed it.
I also removed CLD since I don't think it's needed.
If the increment of a loop control number is 1, it can be omitted as it is the default.
Find all posts by this user
Quote this message in a reply
09-13-2024, 07:37 AM (This post was last modified: 09-13-2024 09:58 PM by Thomas Klemm.)
Post: #6
RE: Powerball Generator!
If the result in "PBALL" is no longer needed, it can be converted into a [ 5×1 matrix ] and the storage of the Powerball lucky number is no longer necessary:
Code:
00 { 81-Byte Prgm }
01▸LBL "PBALL"
02 CLA
03 5
04 STO 00
05 1
06 DIM "PBALL"
07 INDEX "PBALL"
08▸LBL 01
09 RCL 00
10 1
11 STOIJ
12 69
13 XEQ 00
14 [FIND]
15 GTO 01
16 STOEL
17 ├" "
18 AIP
19 DSE 00
20 GTO 01
21 26
22 XEQ 00
23 ├" PB: "
24 AIP
25 AVIEW
26 RTN
27▸LBL 00
28 RAN
29 ×
30 IP
31 1
32 +
33 END
I also replaced ISG with DSE.
Find all posts by this user
Quote this message in a reply
09-13-2024, 08:26 PM
Post: #7
RE: Powerball Generator!
My Texas Lottery HP 42S program:

LBL “LOT”
RAN
54
*
1
+
IP
STOP
GTO “LOT”
RTN

I like generating 1 number at a time for filling out my single ticket purchase each week. R/S for each additional number, R/S if I get a repeated number. On my HP 50, I programmed it to only present a non reapeating 1 row matrix of 6 numbers.

I would have the same chance of a win if I simply chose 1,2,3,4,5,6 !
Find all posts by this user
Quote this message in a reply
09-13-2024, 10:20 PM
Post: #8
RE: Powerball Generator!
(09-13-2024 08:26 PM)lrdheat Wrote:  On my HP 50, I programmed it to only present a non reapeating 1 row matrix of 6 numbers.

We can adapt the existing program very easily:
Code:
00 { 53-Byte Prgm }
01▸LBL "LOT"
02 6
03 STO 00
04 1
05 DIM "LOT"
06 INDEX "LOT"
07▸LBL 01
08 RCL 00
09 1
10 STOIJ
11 54
12 RAN
13 ×
14 IP
15 1
16 +
17 [FIND]
18 GTO 01
19 STOEL
20 DSE 00
21 GTO 01
22 RCL "LOT"
23 END
Find all posts by this user
Quote this message in a reply
09-14-2024, 11:27 AM
Post: #9
RE: Powerball Generator!
(09-13-2024 08:26 PM)lrdheat Wrote:  ... On my HP 50, I programmed it to only present a non repeating 1 row matrix of 6 numbers.

I would have the same chance of a win if I simply chose 1,2,3,4,5,6 !

Indeed the chance of winning is minuscule but at least we get some entertainment by programming our HP's Smile

This is my Powerball program for the HP 50 using ListExt and LSORT. It returns a list of 5 numbers in the range 1..69 on level 2 and a number in the range 1..26 on level 1. For MegaMillions (the other US multi-state lottery) replace the 69 with 70 and replace the 26 with 25.

Code:

\<< 69 LSEQ             @ List of numbers 1..69
    LSHUF               @ Shuffle list
    5 LTAKE LSORT       @ Take first 5 numbers and sort
    RAND 26. * IP 1. +  @ Random integer in range 1..26
    R\->I               @ Convert to exact integer for display
\>>
Find all posts by this user
Quote this message in a reply
09-14-2024, 12:41 PM
Post: #10
RE: Powerball Generator!
Now if someone could just come up with a program that generates the winning numbers Smile

A1

HP-15C (2234A02xxx), HP-16C (2403A02xxx), HP-15C CE (9CJ323-03xxx), HP-20S (2844A16xxx), HP-12C+ (9CJ251)

Find all posts by this user
Quote this message in a reply
09-14-2024, 03:13 PM (This post was last modified: 09-14-2024 03:14 PM by C.Ret.)
Post: #11
RE: Powerball Generator!
(09-14-2024 12:41 PM)AnnoyedOne Wrote:  Now if someone could just come up with a program that generates the winning numbers

It is possible, but it requires a lot more calculations than what I see in the codes above.

But if by chance you have an HP-41C (or something perfectly compatible), then there is still time to play the Power Balls that this program displays:

[Image: attachment.php?aid=13947]

P.S.: Know that I will only take a tiny fraction of the winnings, but for all the players who win by using my code.


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
09-14-2024, 03:45 PM
Post: #12
RE: Powerball Generator!
(09-14-2024 03:13 PM)C.Ret Wrote:  P.S.: Know that I will only take a tiny fraction of the winnings...

Would 10% be enough? Smile With payment after I receive the winnings!

A1

HP-15C (2234A02xxx), HP-16C (2403A02xxx), HP-15C CE (9CJ323-03xxx), HP-20S (2844A16xxx), HP-12C+ (9CJ251)

Find all posts by this user
Quote this message in a reply
09-14-2024, 04:43 PM
Post: #13
RE: Powerball Generator!
(09-14-2024 03:13 PM)C.Ret Wrote:  But if by chance you have an HP-41C (or something perfectly compatible), then there is still time to play the Power Balls that this program displays:

A bit shorter:
Code:
01▸LBL "SEPT14"
02 "11,27,31,36,67:"
03 "├11"
04 AVIEW
05 END
Find all posts by this user
Quote this message in a reply
09-14-2024, 06:40 PM
Post: #14
RE: Powerball Generator!
(09-13-2024 08:26 PM)lrdheat Wrote:  I would have the same chance of a win if I simply chose 1,2,3,4,5,6 !

Back when I was a teenager, I said this same thing to an uncle of mine in upstate New York, when they had a state lottery and I wanted to buy a ticket. My uncle had been around (horses, poker, other types of gambling), and he said that I was incorrect in my assertion (NOT the words he used). I didn’t believe him. Many years later, I did some research on conditional probabilities (conditional because you are choosing a set of numbers based on what you have already chosen, in order for them to be so close to each other). Turns out he was correct: some sets of lottery numbers are less likely to occur than others.

The lessons: always listen to your elders, because you might learn something. Also, math is interesting.

DGM
HP25, HP55, HP27S, HP18C, HP19C, HP16C, HP67, HP28, HP41, HP75, HP71, HP48C, HP49G, HP30B, HP50G, HP Prime (not necessarily in that order)
Find all posts by this user
Quote this message in a reply
09-23-2024, 12:39 PM
Post: #15
RE: Powerball Generator!
I'm curious about this.

Have there been enough lottery drawings to be statistically significant?

(09-14-2024 06:40 PM)DGM Wrote:  
(09-13-2024 08:26 PM)lrdheat Wrote:  I would have the same chance of a win if I simply chose 1,2,3,4,5,6 !

Back when I was a teenager, I said this same thing to an uncle of mine in upstate New York, when they had a state lottery and I wanted to buy a ticket. My uncle had been around (horses, poker, other types of gambling), and he said that I was incorrect in my assertion (NOT the words he used). I didn’t believe him. Many years later, I did some research on conditional probabilities (conditional because you are choosing a set of numbers based on what you have already chosen, in order for them to be so close to each other). Turns out he was correct: some sets of lottery numbers are less likely to occur than others.

The lessons: always listen to your elders, because you might learn something. Also, math is interesting.

DGM
HP25, HP55, HP27S, HP18C, HP19C, HP16C, HP67, HP28, HP41, HP75, HP71, HP48C, HP49G, HP30B, HP50G, HP Prime (not necessarily in that order)
Find all posts by this user
Quote this message in a reply
09-23-2024, 02:04 PM
Post: #16
RE: Powerball Generator!
The Texas lottery has 6 non repeating integers chosen from 1 through 54. There are 25,827,165 individual combinations of those numbers available, 1 of which is 1,2,3,4,5,6. Each of the combinations of 6 numbers from 1,2,3,4,5,6 up to 49,50,51,52,53,54 has the same chance of occurrence. It is true that sub classes of interesting sets composed of consecutive numbers is small compared to the large number of sets with uninteresting, seemingly patternless random look to the numbers. Yet, each particular set of 6 has a 1 in 25,827,165 chance of being chosen, at which point it becomes quite interesting!
Find all posts by this user
Quote this message in a reply
09-23-2024, 03:52 PM
Post: #17
RE: Powerball Generator!
(09-23-2024 02:04 PM)lrdheat Wrote:  The Texas lottery has 6 non repeating integers chosen from 1 through 54. There are 25,827,165 individual combinations of those numbers available, 1 of which is 1,2,3,4,5,6. Each of the combinations of 6 numbers from 1,2,3,4,5,6 up to 49,50,51,52,53,54 has the same chance of occurrence. It is true that sub classes of interesting sets composed of consecutive numbers is small compared to the large number of sets with uninteresting, seemingly patternless random look to the numbers. Yet, each particular set of 6 has a 1 in 25,827,165 chance of being chosen, at which point it becomes quite interesting!

I think where we are being bogged down is with the word “particular”. Yes, it is true that any combination can occur, but one in which the numbers are consecutive is less likely than one in which they are not.

I don’t believe that there have been enough lottery draws recorded to be statistically significant, however.

Maybe this can help to explain it?
Math Stack Exchange

DGM
Find all posts by this user
Quote this message in a reply
09-23-2024, 04:04 PM
Post: #18
RE: Powerball Generator!
(09-23-2024 02:04 PM)lrdheat Wrote:  The Texas lottery has 6 non repeating integers chosen from 1 through 54. There are 25,827,165 individual combinations of those numbers available, 1 of which is 1,2,3,4,5,6. Each of the combinations of 6 numbers from 1,2,3,4,5,6 up to 49,50,51,52,53,54 has the same chance of occurrence. It is true that sub classes of interesting sets composed of consecutive numbers is small compared to the large number of sets with uninteresting, seemingly patternless random look to the numbers. Yet, each particular set of 6 has a 1 in 25,827,165 chance of being chosen, at which point it becomes quite interesting!

Where there is an effect is that the chance a number combination will be played is not uniformly distributed, so if there is any pot splitting, you are more likely to see the prize split up with certain number picks.

One common way for people to select their numbers is using dates, so playing the numbers 1 to 31 are more likely to match up with other players.

Arithmetic progressions are also commonly played. During one early high jackpot week the Washington State lottery put out a message warning against playing the numbers down the right side of the card. These numbers were played so often that if they came up as the winning draw the jackpot would be split so that each winner would only get a bit more than a thousand dollars.

I did some analysis and found that winning draws with arithmetic progressions for more than 3 of the numbers would get statistically more matches on the 2-, 3-, and 4- number prizes. I considered avoiding number selections like these to better my odds of being the sole winner of the jackpot. At the time the state lottery was only a 7 million to 1 odds, and if the pot got well above 7 million dollars, they would often sell more than 7 million tickets making it likely the pot would be split.

I also found some anomalies in the distribution of numbers if I let the lottery machines pick my numbers. I'm not sure what was going on, but I think they were trying to prevent selling tickets with matching sets, so the picks were not independent, but they were doing it in a way that tended to generate more 2 or 3 matches between the selections than you would expect from independent picks (a $10 ticket would have 20 sets of numbers, which was enough to get a statistically significant effect). I never figured out if that was a bug or a feature, since you would be more likely to have multiple small prizes on a single ticket. Though that was at the expense of each ticket being slightly less likely to win at all. For this reason I wrote a program for my calculator to pick numbers for me.

513016415223221833242338122322514610315
Find all posts by this user
Quote this message in a reply
09-23-2024, 04:17 PM
Post: #19
RE: Powerball Generator!
(09-23-2024 03:52 PM)DGM Wrote:  Yes, it is true that any combination can occur, but one in which the numbers are consecutive is less likely than one in which they are not.
But that doesn’t make the sequence 1-6 less likely than any other combination. Your uncle was simply wrong. Looks like you are mixing up answers to two completely different questions. I cannot but add +1 to lrdheat’s comment.

Or maybe you are trying to say something different than we read in your words. Maybe a different wording or example would help?
Find all posts by this user
Quote this message in a reply
09-23-2024, 05:26 PM
Post: #20
RE: Powerball Generator!
Okay, let us try a simple example:
Pick 3 numbers out of 20, with no duplications. What are the odds of them being three consecutive numbers? There are 1,140 possibilities. Only 108 of them would have 3 consecutive numbers (18 sets beginning with 1-18, times 6 permutations of each, because they are chosen in any order). So, you have one chance in about 10.55555 of ANY of your picks being ANY three consecutive numbers. Doesn’t that show that random picks coming up with consecutive numbers are less likely than ones which do not have consecutive numbers? Or is my thinking wrong?

By the way, I started with 3 out of 6, but the odds didn’t work out as well. Now, most lotteries use a much larger range of numbers and a greater number of things to pick.

I think my uncle was right.

DGM
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 10 Guest(s)