powerball
My attempt at predicting Powerball numbers with nodejs
See it in action here
command-line
I included the command powerball
, if you install with npm install -g powerball
that will predict/check numbers.
Usage: powerball [options] [numbers]
Options:
-h, --help Show help
--count, -c Count of number sets to return. [default: 10]
--powerplay, -p For checking: did you enable powerplay? [boolean]
--time, -t What time should the rules be pulled from? [default: now]
Examples:
powerball -c 5 Get 5 numbersto play
powerball 01 18 41 43 46 22 See if your numbers got pulled in last draw
Objects
- Statistical :
object
- Powerball :
object
object
Statistical : Kind: global namespace
- Statistical :
object
- .μ(freq) ⇒
Number
- .gmean(freq) ⇒
Number
- .median(freq) ⇒
Number
- .range(freq) ⇒
Array
- .σ(freq) ⇒
Number
- .μ(freq) ⇒
Number
Statistical.μ(freq) ⇒ Calculate arithmetic mean of ball-count
Kind: static method of Statistical
Returns: Number
- Arithmatic Mean of weights
Param | Type | Description |
---|---|---|
freq | Object |
A single ball-frequency array from frequencies |
Example (Get Arithmetic Mean of Red Balls)
var f = powerball.frequencies(winners)
console.log(powerball.μ(f.red))
Example (Get Arithmetic Mean of White Balls)
console.log(powerball.mean(f.white))
Number
Statistical.gmean(freq) ⇒ Calculate geometric mean of ball-count
Kind: static method of Statistical
Returns: Number
- Geometric Mean of weights
Param | Type | Description |
---|---|---|
freq | Object |
A single ball-frequency array from frequencies |
Example (Get Geometric Mean of Red Balls)
var f = powerball.frequencies(winners)
console.log(powerball.gmean(f.red))
Example (Get Geometric Mean of White Balls)
console.log(powerball.gmean(f.white))
Number
Statistical.median(freq) ⇒ Calculate median of ball-count
Kind: static method of Statistical
Returns: Number
- Median of weights
Param | Type | Description |
---|---|---|
freq | Object |
A single ball-frequency array from frequencies |
Example (Get Median of Red Balls)
var f = powerball.frequencies(winners)
console.log(powerball.median(f.red))
Example (Get Median of White Balls)
console.log(powerball.median(f.white))
Array
Statistical.range(freq) ⇒ Calculate range of ball-count
Kind: static method of Statistical
Returns: Array
- High/low range of numbers for weights.
Param | Type | Description |
---|---|---|
freq | Object |
A single ball-frequency array from frequencies |
Example (Get Range of Red Balls)
var f = powerball.frequencies(winners)
console.log(powerball.range(f.red))
Example (Get Range of White Balls)
console.log(powerball.range(f.white))
Number
Statistical.σ(freq) ⇒ Calculate standard deviation of ball-count
Kind: static method of Statistical
Returns: Number
- Standard Deviation of weights
Param | Type | Description |
---|---|---|
freq | Object |
A single ball-frequency array from frequencies |
Example (Get Standard Deviation of Red Balls)
var f = powerball.frequencies(winners)
console.log(powerball.stddev(f.red))
Example (Get Standard Deviation of White Balls)
console.log(powerball.σ(f.white))
object
Powerball : Kind: global namespace
- Powerball :
object
- .balls([date]) ⇒
Array
- .numbers() ⇒
Promise
- .frequencies(winners) ⇒
Object
- .predict(white, red, [time]) ⇒
Array
- .payout(pick, winner, powerplay) ⇒
Boolean
|Number
- .balls([date]) ⇒
Array
Powerball.balls([date]) ⇒ Get ball-maxes for a given date
Kind: static method of Powerball
Returns: Array
- white, red ball-max
Param | Type | Default | Description |
---|---|---|---|
[date] | Date |
now |
Date to check |
Example (Current Ball Maxes)
// returns [69, 26]
powerball.balls()
Example (Old Ball Maxes)
// returns [59, 39]
powerball.balls(new Date('1/8/2009'))
Promise
Powerball.numbers() ⇒ Get past winning numbers
Kind: static method of Powerball
Returns: Promise
- Resolves to array of winner objects
Example (Get Current Numbers)
powerball.numbers().then(winners => {
console.log(winners)
})
Object
Powerball.frequencies(winners) ⇒ Calculate frequencies of white & red balls
Kind: static method of Powerball
Returns: Object
- keyed with number, value is frequency
Param | Type | Description |
---|---|---|
winners | Array |
The winning numbers from numbers |
Example (Get Frequency Counts)
console.log(powerball.frequencies(winners))
Array
Powerball.predict(white, red, [time]) ⇒ Predict winning numbers
Kind: static method of Powerball
Returns: Array
- The numbers you should play
Param | Type | Default | Description |
---|---|---|---|
white | Object |
White ball-frequency array from frequencies | |
red | Object |
Red ball-frequency array from frequencies | |
[time] | Date |
now |
Different dates have differnt ball-sets |
Example (Get Prediction)
var f = powerball.frequencies(winners)
console.log(powerball.predict(f.white, f.red))
Example (Predict For an Old Date)
console.log(powerball.predict(f.white, f.red, new Date('1/1/98')))
Boolean
| Number
Powerball.payout(pick, winner, powerplay) ⇒ Check if your numbers won (only current rules) http://www.powerball.com/powerball/pb_prizes.asp
Kind: static method of Powerball
Returns: Boolean
| Number
- true for jackpot, if Number: amount you won
Param | Type | Description |
---|---|---|
pick | Array |
Your number picks (6-length array) |
winner | Object |
A single draw from number() |
powerplay | Boolean |
Did you mark power-play on your ticket? |
Example (Check If You Won)
powerball.numbers().then(winners => {
console.log(powerbal.payout([5, 6, 10, 36, 43, 11], winners.pop(), true))
})