Citat:
uppdaterad kod baserad på vinsttabellen för triss 40:
resultat denna körning med 2000 rundor:
Average win: 5,279.85 kr
Max win: 270,230.00 kr
Min win: 2,300.00 kr
Q1 (25th percentile): 3590.0
Q2 (Median): 3920.0
Q3 (75th percentile): 4310.0
Net average profit (ticket cost = 300*30 kr): -3,720.15 kr
Kod:
import numpy as np winamount = [2765000, 1000000, 265000, 200000, 100000, 50000, 20000, 10000, 5000, 2500, 2000, 1500, 1000, 900, 750, 600, 500, 450, 400, 300, 200, 180, 150, 120, 90, 80, 60, 40, 0 ] numberof = [1, 2, 25, 1, 2, 3, 7, 46, 30, 16, 50, 80, 150, 60, 50, 200, 190, 110, 280, 500, 760, 900, 2660, 6000, 23500, 91675, 77000, 249500, 1546202] total = 2000000 prob= np.array(numberof) / total print(prob) winamount_array = np.array(winamount) results = [] rounds = 2000 del len num_win_amounts = len(winamount) # Create a pool of tickets based on numberof ticket_pool = [] for i in range(num_win_amounts): ticket_pool.extend([winamount[i]] * numberof[i]) # Convert the pool to a numpy array for efficient sampling ticket_pool = np.array(ticket_pool) for _ in range(rounds): # Draw 300 tickets from the pool without replacement draw = np.random.choice(ticket_pool, size=300, replace=False) total_win = np.sum(draw) results.append(total_win) results = np.array(results) mean_win = np.mean(results) max_win = np.max(results) min_win = np.min(results) q1 = np.percentile(results, 25) q2 = np.percentile(results, 50) q3 = np.percentile(results, 75) import matplotlib.pyplot as plt # === Plot histogram of total wins === plt.figure(figsize=(10, 6)) plt.hist(results, bins=50, color='skyblue', edgecolor='black') plt.title("Histogram of Total Winnings per 300 Tickets (10,000 Draws)") plt.xlabel("Total Win (kr)") plt.ylabel("Number of Draws") plt.grid(True) plt.axvline(mean_win, color='red', linestyle='dashed', linewidth=2, label=f'Mean: {mean_win:,.0f} kr') plt.legend() plt.show() # === Print summary stats === print(f"Average win: {mean_win:,.2f} kr") print(f"Max win: {max_win:,.2f} kr") print(f"Min win: {min_win:,.2f} kr") print(f"Q1 (25th percentile): {q1}") print(f"Q2 (Median): {q2}") print(f"Q3 (75th percentile): {q3}") print(f"Net average profit (ticket cost = 300*30 kr): {mean_win - 9000:,.2f} kr")
resultat denna körning med 2000 rundor:
Average win: 5,279.85 kr
Max win: 270,230.00 kr
Min win: 2,300.00 kr
Q1 (25th percentile): 3590.0
Q2 (Median): 3920.0
Q3 (75th percentile): 4310.0
Net average profit (ticket cost = 300*30 kr): -3,720.15 kr
Bra jobbat!

__________________
Senast redigerad av StoreSvarte 2025-07-10 kl. 23:25.
Senast redigerad av StoreSvarte 2025-07-10 kl. 23:25.