๐ฑ๋ก๋?
๊ฐ์๊ธฐ ๋ก๋๋ ์ด๋์ ํ์ด๋์จ ๊ฑฐ๋๊ณ ๋ฌผ์ด๋ณผ ์๋ ์๊ฒ ๋ค. ์ฃผ๊ฐ ์์ธก ๋ชจ๋ธ์ ๋ง๋ค ๋ ์์ฃผ? ์ฌ์ฉํ๋? ๋ณผ ์ ์๋? ๋ฌด์์ ํ๋ฅ ์ ๋ค๋ฃจ๋ method๋ค ์ค์์ MCS์ Brownian method ๋ฑ์ด ์๋ค. ๊ทธ ์ค์์ MCS๋ก ํ ๋ฒ ๋์๋ณด๊ณ ์ถ์๋ฐ ๊ฐ์ฅ ๋ง๋งํ๊ณ ์ฌ๋ฐ์ด ๋ณด์ด๋ Lotto๋ฅผ ์ฌ์ฉํด๋ณด๊ธฐ๋ก ํ๋ค.
๋ชฉ์
๋ด๊ฐ ์ด๋ ๊ฒ ๋จ์ํ ์ฝ๋๋ก ์คํํ๋ ์๋ง ๋ฒ์ ์ํ์ ํตํด์ ์ป๊ณ ์ ํ๋ ๊ฒ์ด ๋ฌด์์ธ๊ฐ?
์ผ๋จ ๋ชฌํ
์นด๋ฅผ๋ก ์๋ฎฌ๋ ์ด์
์ ํตํด์ ์์น์ ์ธ ํ๋ฅ ๊ณผ ์ง์ ์ํ ํ๋ฅ ์ ์ฐจ์ด๋ฅผ ํ์ธํด ๋ณผ ์ ์๊ฒ ์ง?
๋ํ ๋ก๋์ ๊ฐ์ ํํ์ฃผ์๊ฐ ๊น๋ค์ด์๋ ๋์ด์๋ ๋ฌด์์ด ์ค์ํ๊ฐ? ๊ณผ์ฐ ๋ด๊ฐ ์ฌ๋ ๋ก๋ 1์ฅ์ ๋ํ ๊ธฐ๋๊ฐ์ ์ด๊ณผ๋ ์๊ฐํด๋ณผ ์๋ฐ์ ์์ ๊ฒ ๊ฐ๋ค. ๋๋ง ๊ทธ๋ฌ๋? ใ
ใ
Powerball์์์ ๊ฐ์
์๊ฐ๋ณด๋ค ์ดํดํด์ผ ํ๋ ๋ฃฐ๋ ์์๊ณ simulation์ ๋ํ ๊ฒฐ๊ณผ๋ฅผ ํด์ํ๊ธฐ ์ํด ๋ฐ๋ก ๊ฐ์ ํด์ผ ํ๋ ๋ถ๋ถ๋ค๋ ์์ด์ ๊ท์ฐฎ์๋ค^^. ๊ทธ๋ฅ ์ ๋๊ฒ ์ซ์ ๋ฝ๊ธฐ ๋์ดํ๋ฉด ๋๋์ค
1. ๋ฏธ๊ตญ์ powerball์ ๊ธฐ์ค์ผ๋ก ํ๊ฒ ๋ค. Powerball์ (1~69)์์ ๋ฒํธ 5๊ฐ, (1~26)์์ ๋ฒํธ 1๊ฐ(๋ณด๋์ค)๋ฅผ ๋ฝ๋๋ค. ๊ทธ๋ฆฌ๊ณ 6๊ฐ ๋ค ์ผ์นํด์ผ Jackpot์ด๋ค.
2. ์ฒซ ๋ฒ์งธ pool 1~69์์ 5๊ฐ ๋ฐ๋ก, ๋ ๋ฒ์งธ pool 1~26์์ 1๊ฐ ๋ฐ๋ก ๋ฝ๋๋ค. ์ฒซ ๋ฒ์งธ pool์ ์ซ์์ ๋ ๋ฒ์งธ pool์์ ๋ฝ์ ์ซ์๊ฐ ์ผ์นํ ์ ์๋ค. (๋์ ์์ ํ ๋ค๋ฅธ pool๋ก ์ดํดํ๋ ๊ฒ์ด ํธ์)
3. ๊ณ์ฐ์ ํธ์๋ฅผ ์ํ์ฌ Jackpot์๋ง ์๊ธ์ ์ฃผ๊ฒ ๋ค.
๋น์ฒจ ๊ธ์ก์์์ ๊ฐ์
3/29๊ธฐ์ค ์ด๋ฒ ๋น์ฒจ ๊ธ์ก = 9350์ต
์ผ๋จ ํ์ฌ๋ ๋น์ฒจ ํ๋ฅ ์ ๊ธฐ์ค์ผ๋ก ๋น์ฒจ ๊ธ์ก์ด ์ธก์ ๋๋ ๊ฒ์ ์๋๋ค
4/2๊ธฐ์ค(ํ๊ตญ)์ผ๋ก jackpot ๊ธ์ก $1bil
picture from powerball ๊ณต์์ฌ์ดํธ
- ticket sold = 292,201,338 and $2 per play
4/2(ํ๊ตญ ๊ธฐ์ค)์ผ๋ก ๊ฐ์ฅ ์ต๊ทผ powerball์ ticket sold๋ฅผ ๊ธฐ์ค์ผ๋ก ํ๊ฒ ๋ค. - On average, between 20 and 24 percent of Powerball prize winners choose to add the Power Play option to their tickets when the jackpot is $150 million or less. This percentage drops to around 14 to 16 percent for larger jackpots. This indicates that a significant majority of players opt for the standard ticket without additional options.
-> ์์ ์ ๋ณด๋ฅผ ๋ฐํ์ผ๋ก ์ด๊ธฐ ๋น์ฒจ ๊ธ์ก์ ์ ํ๊ฒ ๋ค. - ๊ธฐ๋ณธ์ ์ผ๋ก ์ ์ฒด ticket sale ๊ธ์ก์ 50% * 60~68% + ์ด์ ๊ธ์ก์ด jackpot ๊ฐ๊ฒฉ์ผ๋ก ๊ฒฐ์ ๋๋ค.
์ด๊ธฐ ๋น์ฒจ ๊ธ์ก ์ค์
base_ticket_sales = 292000000 * 2 # Total revenue from ticket sales base_jackpot = 0.5 * 0.65 * base_ticket_sales # Starting jackpot jackpot = base_jackpot # Current jackpot rollovers = 0 # Count of rollovers
์ด๊ฑด ๊ทธ๋ฅ ๊ณ์ฐ๊ธฐ๋ก ๋๋๋ ค๋ ๋๋๊ฑฐ ์๋? ํํผ ๊ธ์ก์ $189,818,980 -> ํํ๋ก ์ฝ 2640์ต(6/23 ๊ธฐ์ค) ใ
ใ
Apr 1, 2024 ๊ธฐ์ค์ผ๋ก 1 ๋น๋ฆฌ์ธ ๋ฌ๋ฌ = ์ฝ 11์กฐ(April Fool's day๋ผ๊ณ ๊ตฌ๋ผ์น๋๊ฑฐ ์๋?)
์คํ๊ณผ์
์ค์ ๋น์ฒจ ํ๋ฅ ๊ณผ ๋น๊ต
์ค์ ๋น์ฒจ ํ๋ฅ = 1/ (69์์ 5๊ฐ ์ซ์ ๋ฝ๊ณ * 26๊ฐ์์ 1๊ฐ) = 1 / 292,201,388 -> 3.42ร10โ9
์คํ ์ฝ๋
import numpy as npdef simulate_powerball_jackpot(iterations=10000): base_ticket_sales = 292000000 * 2 # Total revenue from ticket sales base_jackpot = 0.5 * 0.65 * base_ticket_sales # Starting jackpot jackpot = base_jackpot # Current jackpot rollovers = 0 # Count of rollovers for _ in range(iterations): # Simulate winning numbers winning_numbers = set(np.random.choice(range(1, 70), 5, replace=False)) winning_powerball = np.random.choice(range(1, 27)) # Assume no winning ticket this iteration winner_found = False # For simplification, we check a subset of tickets instead of all 292,000,000 # Adjust 'num_tickets_simulated' as needed for computational efficiency vs accuracy num_tickets_simulated = 10000 # Example: Simulate 10,000 tickets for each iteration for _ in range(num_tickets_simulated): ticket_numbers = set(np.random.choice(range(1, 70), 5, replace=False)) ticket_powerball = np.random.choice(range(1, 27)) if ticket_numbers == winning_numbers and ticket_powerball == winning_powerball: winner_found = True break # Exit the loop early if a winning ticket is found if not winner_found: # If no winner, the jackpot rolls over: Increase by a fraction of base jackpot jackpot += base_jackpot # Example: 50% of the base jackpot is added each rollover rollovers += 1 else: # If there's a winner, reset the jackpot for the next iteration jackpot = base_jackpot # Reset jackpot after win # Calculate average jackpot considering rollovers # Note: This simplistic model divides the total accumulated jackpot by the number of iterations # For more accuracy, track and average only jackpots in winning iterations average_jackpot = jackpot / iterations return average_jackpot, rollovers# Run the simulationaverage_jackpot, rollovers = simulate_powerball_jackpot()print(f"Estimated Average Jackpot Value: ${average_jackpot:,.2f} with {rollovers} rollovers")
๋ณธ ์ฝ๋๋ ์์์ ์ค์ ํ ์ด๊ธฐ ๋น์ฒจ ๊ธ์ก์ผ๋ก ๋งค ํ๋ง๋ค ์ผ์ ํ๊ฒ ๋ก๋ ํฐ์ผ์ด ํ๋งค๋๋ค๊ณ ๊ฐ์ ํ๊ณ ์คํํ๋ค.
๊ทธ๋ฆฌ๊ณ rollover๊ฐ ์๊ธฐ๋ฉด ์ด์ ๊ธ์ก์ผ๋ก ๋ํด์ฃผ๋๋ฐ, ๋ง์ง๋ง์ iteration์ผ๋ก ๋๋ ์ฃผ๊ธฐ ๋๋ฌธ์, estimated average jackpot value๋ผ๋ ์ด๋ฆ์ผ๋ก ๊ฐ์ด ๋์จ๋ค.
๊ทธ๋์ ๋ฐ์์ 1๋ฒ๋ ๋น์ฒจ์ด ์๋๋ค๋ฉด, average $189,818,980์ผ๋ก ๊ฒฐ๊ณผ๊ฐ ๋์ค๋ ๊ฒ์ด๋ค.
์ง๊ธ ์๊ฐํด๋ณด๋ฉด ์ ์ด๋ ๊ฒ ์ถ๋ ฅํ์ง? ๊ทธ๋ฅ ๋น์ฒจ ํ๋ฅ ๋ง ๋์ค๋ฉด ๋๋๋ฐ, ๊ทธ๋ฆฌ๊ณ ๋น์ฒจ ์์ ์ ๋น์ฒจ ๊ธ์ก์ด reset๋๊ธฐ ๋๋ฌธ์; ๋ ์ธ์ ๋น์ฒจ๋์๋ ๊ฒ์ธ์ง ์ง์ ๊ณ์ฐํด์ผ ํ์์ ๋ฉ์ฒญ์^^
์คํ ๊ฒฐ๊ณผ
iterations: 10000, nums_tickets_simulated = 5000
-> 1๋ฒ ๋น์ฒจiterations: 10000, nums_tickets_simulated = 10000
-> ๋น์ฒจ Xiterations: 10000, nums_tickets_simulated = 20000
-> ๋น์ฒจ Xiterations: 10000, nums_tickets_simulated = 30000
-> 2๋ฒ ๋น์ฒจiterations: 10000, nums_tickets_simulated = 40000
-> ๋น์ฒจ X
๊ฒฐ๊ณผ ํด์
์ ๋ต์ ์ ํด๋๋ ๊ฒ์ด ์๋๋ผ ๋งค ์๋ฎฌ๋ ์ด์
๋ง๋ค ์ ๋ต์ง ํ๋ฒ, ๊ทธ๋ฆฌ๊ณ generate a set of ticket numbers for each ticket sold๋ก ํ๋ฅ ์ ๊ณ์ฐํ๋ค.
10,000๋ฒ์ ๋ก๋ ๋ฐฉ์ก์ด ์์๋ ๊ฒ์ด๊ณ ๊ทธ ๋๋ง๋ค nums_tickets_simulated ์ซ์ ๋งํผ ํ๋งค์๊ฐ ์์๋ค๊ณ ์๊ฐํ๋ฉด ๋ ๊ฒ ๊ฐ๋ค.
๊ทผ๋ฐ ์ด๊ฒ ์ค์ํ ๊ฒ์ด ์๋ ๊ฒ ๊ฐ๋ค
๊ฐ๋จํ๊ฒ ์ค์ ํ๋ฅ vs MCS ํ๋ฅ vs ์์น์ ํ๋ฅ ๋ง ์ดํด๋ณด์
- ์์น์ ๋น์ฒจ ํ๋ฅ = 1/ (69์์ 5๊ฐ ์ซ์ ๋ฝ๊ณ * 26๊ฐ์์ 1๊ฐ) = 1 / 292,201,388 -> 3.42ร10โ9
- MCS ๋น์ฒจ ํ๋ฅ (์คํ ๊ฒฐ๊ณผ) = 10000ร(5000+10000+20000+30000+40000)/(1+0+0+2+0)=2.85ร10โ9
-> ๋์ ํ๋ฅ ์ด ๊ฑฐ์ ๋น์ทํ ๊ฒ์ ํ์ธํ ์ ์๋ค. - ์ค์ ๋น์ฒจ ํ๋ฅ (๊ฐ์ฅ ์ต๊ทผ) -> ๋์ถฉ ํฐ์ผ ํ์ฅ๋น $2๋ก ๊ฐ์ ํ๊ณ $233 mil๊น์ง rollover ๋๊ณ 15๋ฒ์งธ ์ํ์์ ๋น์ฒจ์๊ฐ ๋ฐ์ํ๋ค. ์คํ๊ต์์ ํ๋ฅ ์ ๋ฐฐ์ด ์์ด๋ง๋ฅ ๊ณ์ฐํ๊ฒ ๋ค. N์ ์์น์ ๋น์ฒจ ํ๋ฅ ์์ ๊ตฌํ powerball ์ ์ฒด ๊ฒฝ์ฐ์ ์์ด๋ค.
# Given the parameters, we need to calculate the following probability:# P = [(1 - 1/N)^(116,500,000)]^14 * (1 - (1 - 1/N)^(116,500,000))# where N is 292,201,388N = 292201388tickets_sold_per_draw = 116500000# Calculating probability of no winner in one drawno_winner_one_draw = (1 - 1/N) ** tickets_sold_per_draw# Calculating probability of no winner for 14 consecutive drawsno_winner_fourteen_draws = no_winner_one_draw ** 14# Calculating probability of at least one winner in the 15th drawwinner_fifteenth_draw = 1 - no_winner_one_draw# Total probabilitytotal_probability = no_winner_fourteen_draws * winner_fifteenth_drawtotal_probability
๊ฒฐ๊ณผ๋ ๋ค์๊ณผ ๊ฐ๋ค
0.001238 or about 0.1238%์๋ ์ด ์ ๋๋ฉด ๋ก๋๊ฐ ๋ฏธ๋ ๋ง๋ ๊ฒ ๊ฐ์๋ฐ?
๋ ์ง | ๋น์ฒจ | jackpot ๊ธ์ก | ์ค์ ์๋ น ๊ธ์ก |
---|---|---|---|
5์ 6์ผ | 1 winner | $215 mil | $100.1 mil |
5์ 8์ผ | no winner | $20 mil | $9.3 mil |
5์ 11์ผ | no winner | $37 mil | $17.4 mil |
5์ 13์ผ | no winner | $48 mil | $22.4 mil |
5์ 15์ผ | no winner | $60 mil | $28.1 mil |
5์ 18์ผ | no winner | $78 mil | $36.4 mil |
5์ 20์ผ | no winner | $89 mil | $41.6 mil |
5์ 22์ผ | no winner | $102 mil | $47.8 mil |
5์ 25์ผ | no winner | $121 mil | $56.7 mil |
5์ 27์ผ | no winner | $131 mil | $61.2 mil |
5์ 29์ผ | no winner | $143 mil | $66.9 mil |
6์ 1์ผ | no winner | $162 mil | $75.3 mil |
6์ 3์ผ | no winner | $173 mil | $80.6 mil |
6์ 5์ผ | no winner | $187 mil | $87.0 mil |
6์ 8์ผ | no winner | $208 mil | $97.7 mil |
6์ 10์ผ | 1 winner | $233 mil | $104.7 mil |
๋๋ MCS๋ฅผ ํด๋ณธ ์ด์ ๋ ์ดํ์ ELS ๊ฐ์ ์ํ ์์ธก์ Random Path๋ฅผ ๊ตฌํ ๋ MCS๋ฅผ ์ฌ์ฉํ๊ฒ ๋๋๋ฐ, MCS์ ๋ํด ์ ์๊ณ ์๋ ์ํ๋ก ๋ค์ด๊ฐ๊ณ ์ถ์ด์ ์์์ 15์๊ฐ์ด๋ ๊ฑธ๋ฆฌ๋ CPU๋ฅผ ๋ถ์ก๊ณ ์ด์ฌํ ์ซ์ ๋ฝ๊ธฐ ๋์ด๋ฅผ ํด๋ณด์๋ค. ๊ทธ๋ฆฌ๊ณ ๋ก๋ ํ๋ฅ ์ ๋ํ ๊ฒฐ๊ณผ ๋ณด๋ค ํ๋ก๊ทธ๋จ์ ๋๋ฆฌ๋ฉด์ ์ด๋ป๊ฒ ํด์์ ๋ด๋์์ผ ํ ์ง ๊ณ ๋ฏผํ๋ ๊ณผ์ ์์ ๋ฐฐ์ด ๋ด์ฉ๋ค์ด ์๊ฐ๋ณด๋ค ๋ง๋คใ ใ
GPU & CPU
๋จผ์ ์์ฒ๋ผ 15์๊ฐ ๋์ ๋์ ๋ถ์ํ ๋
ธํธ๋ถ์ ์ผ๋์์ผ ํ๋ ๊ฒ์ ํด๊ฒฐํ๊ธฐ ์ํด ๋
ธํธ๋ถ์ ์๋ GPU ์ฐ๊ฒฐ์ ์ํด Cuda ์ค์น ๋ฐ ์ฐ๊ฒฐ์ ๊ณต๋ถํ๋ค.
๋ complexํ ์ฝ๋๊ฐ ํ์ํ๊ณ , 10,000๋ฒ iteration์ 40,000์ ticket sales ๊ฐ์ด ์์ scale์ parellel processing์ด ๊ตณ์ด ํ์ ์๋ค๋ ํผ๋๋ฐฑ์ ๋จผ์ ๋ฐ์๋ค.
์ดํ์ ์ฐ๊ฒฐ๋ง ํ๊ณ ๊ฒฐ๊ตญ ์ฌ์ฉ ์ํ๋ค. ์ฝ๋๋ gpu๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฐ๊ฟ์ผ ํ๋ค๋๋ผ^^
Random
Can a computer generate a truly random number?
https://engineering.mit.edu/engage/ask-an-engineer/can-a-computer-generate-a-truly-random-number/
On a completely deterministic machine(์ฐ๋ฆฌ๊ฐ ์ฐ๋ ์ปดํจํฐ) you can't generate anything you could really call a random sequence of numbers.
์ด์ : the machine follows same algorithm to generate them. Meaning, it starts with a common 'seed' number and then follows a pattern. ๊ทธ๋ฆฌ๊ณ ์ฐ๋ฆฌ๋ ์ด๊ฒ์ pseudo-random์ด๋ผ๊ณ ๋ถ๋ฅธ๋ค.
๊ทธ๋ฆฌ๊ณ ์์ lottery ๊ฐ์ ๋ฌธ์ ์์๋ ํฐ ์์ ๋ฒ์น์ ์ํฅ์ ๋ฐ๊ธฐ ๋๋ฌธ์, ์ ์ฉํ๊ธฐ ์ ์ ํ์ง ์์ ์ ์๋ค. ๊ทธ๋๋ random seed๋ฅผ ์ค์ ํ์ง ์์ ์ํ์ code๋ฅผ ์์ฑํ๊ธฐ ๋๋ฌธ์, ์ต์ํ nums_tickets_simulated์ ๋ฐ๋ฅธ ์ํ ๋๋ง๋ค random seed๊ฐ ๋ฌ๋์ ๊ฒ์ด๋ค.์๋ง๋?
Exceptionally good at certain aspects of a thing by just doing it everyday (from Lex Fridman's podcast with Andrew Ng)
๋ณธ ๋ด์ฉ์ ๋๊ตฐ๊ฐ์๊ฒ ์ ๋ณด๋ฅผ ์ ๊ณตํ๊ณ ์ ์์ฑํ ๊ธ์ด ์๋๋ค(์ค๋ ฅ์ด ์๋จ)
๋ณธ์ธ์ด ๊ณต๋ถํ๋ฉด์ ๊นจ๋ฌ์? ๋ด์ฉ๋ค์ ๊ธฐ๋ก ์ฉ๋์์ ๋ฐํ๋ค.
๋ฌดํํ ํผ๋๋ฐฑ๊ณผ ํํด์ ๊ฑธ์ด๋ ๋๋ค. ์๋ถ์ผ๋ก ๊ฐ์ฌํ๊ฒ ๋ฐ์ ๋จน๊ฒ ๋ค.