#!/usr/bin/env python3 """ Eurojackpot Bereichskombinationen-Analyse Analysiert die Kombinationen von Zahlenbereichen in den gezogenen 5er-Kombinationen. Focus auf Z1-Z4 wie gewünscht. """ import pandas as pd from collections import Counter, defaultdict def get_range_for_number(number): """Bestimmt den Bereich für eine gegebene Zahl.""" if 1 <= number <= 10: return 'A(1-10)' elif 11 <= number <= 20: return 'B(11-20)' elif 21 <= number <= 30: return 'C(21-30)' elif 31 <= number <= 40: return 'D(31-40)' elif 41 <= number <= 50: return 'E(41-50)' else: return 'Unknown' def analyze_range_combinations(): """Analysiert Bereichskombinationen in Eurojackpot-Ziehungen.""" # Daten laden df = pd.read_csv("/Users/sebastianfrohlich/Library/Mobile Documents/com~apple~CloudDocs/Jupyter Notebooks/Eurojackpot/data/AlleEurojackpotzahlen.csv", sep=';') print(f"🎲 EUROJACKPOT BEREICHSKOMBINATIONEN-ANALYSE") print(f"Anzahl analysierte Ziehungen: {len(df)}") print("="*60) # Analyse für Z1-Z4 (wie gewünscht) z_columns_z1_z4 = ['Z1', 'Z2', 'Z3', 'Z4'] # Alle Kombinationen sammeln combinations_z1_z4 = [] range_patterns_z1_z4 = [] for _, row in df.iterrows(): # Bereiche für Z1-Z4 bestimmen ranges = [get_range_for_number(row[col]) for col in z_columns_z1_z4] range_pattern = '|'.join(sorted(ranges)) # Sortiert für einheitliche Muster combinations_z1_z4.append(tuple(ranges)) range_patterns_z1_z4.append(range_pattern) # Auch vollständige Z1-Z5 Analyse z_columns_all = ['Z1', 'Z2', 'Z3', 'Z4', 'Z5'] combinations_all = [] range_patterns_all = [] for _, row in df.iterrows(): ranges = [get_range_for_number(row[col]) for col in z_columns_all] range_pattern = '|'.join(sorted(ranges)) combinations_all.append(tuple(ranges)) range_patterns_all.append(range_pattern) # Häufigkeitsanalyse print("\n📊 ANALYSE Z1-Z4 (4 Zahlen):") print("="*40) pattern_counts_z1_z4 = Counter(range_patterns_z1_z4) print(f"Häufigste Bereichskombinationen (Z1-Z4):") for i, (pattern, count) in enumerate(pattern_counts_z1_z4.most_common(15), 1): percentage = (count / len(df)) * 100 print(f"{i:2}. {pattern:30} {count:3}x ({percentage:4.1f}%)") print(f"\n📊 VERGLEICH: ANALYSE Z1-Z5 (alle 5 Zahlen):") print("="*40) pattern_counts_all = Counter(range_patterns_all) print(f"Häufigste Bereichskombinationen (Z1-Z5):") for i, (pattern, count) in enumerate(pattern_counts_all.most_common(15), 1): percentage = (count / len(df)) * 100 print(f"{i:2}. {pattern:35} {count:3}x ({percentage:4.1f}%)") # Analyse der Bereichsverteilung in Kombinationen print(f"\n🎯 BEREICHSVERTEILUNG IN KOMBINATIONEN:") print("="*50) # Wie oft kommt jeder Bereich in Z1-Z4 vor? range_in_combination_counts = defaultdict(int) for combination in combinations_z1_z4: for range_name in set(combination): # set() um Duplikate zu vermeiden range_in_combination_counts[range_name] += 1 print("Häufigkeit der Bereiche in Z1-Z4 Kombinationen:") for range_name in ['A(1-10)', 'B(11-20)', 'C(21-30)', 'D(31-40)', 'E(41-50)']: count = range_in_combination_counts[range_name] percentage = (count / len(df)) * 100 print(f"{range_name}: {count:3} Kombinationen ({percentage:4.1f}%)") # Analyse: Wie viele verschiedene Bereiche pro Kombination? print(f"\n📈 BEREICHSVIELFALT PRO KOMBINATION (Z1-Z4):") print("="*45) diversity_counts = defaultdict(int) for combination in combinations_z1_z4: unique_ranges = len(set(combination)) diversity_counts[unique_ranges] += 1 for num_ranges in sorted(diversity_counts.keys()): count = diversity_counts[num_ranges] percentage = (count / len(df)) * 100 print(f"{num_ranges} verschiedene Bereiche: {count:3} Kombinationen ({percentage:4.1f}%)") # Spezielle Muster print(f"\n🔍 SPEZIELLE MUSTER (Z1-Z4):") print("="*35) # Alle aus dem gleichen Bereich same_range_count = sum(1 for combo in combinations_z1_z4 if len(set(combo)) == 1) print(f"Alle 4 Zahlen aus gleichem Bereich: {same_range_count} ({(same_range_count/len(df)*100):.1f}%)") # Alle aus verschiedenen Bereichen (4 verschiedene) all_different_count = sum(1 for combo in combinations_z1_z4 if len(set(combo)) == 4) print(f"Alle 4 Zahlen aus verschiedenen Bereichen: {all_different_count} ({(all_different_count/len(df)*100):.1f}%)") # Benachbarte Bereiche-Analyse print(f"\n🏠 BENACHBARTE BEREICHE-ANALYSE (Z1-Z4):") print("="*40) adjacent_patterns = { 'A+B': 0, # 1-10 + 11-20 'B+C': 0, # 11-20 + 21-30 'C+D': 0, # 21-30 + 31-40 'D+E': 0, # 31-40 + 41-50 } for combination in combinations_z1_z4: ranges_set = set(combination) if 'A(1-10)' in ranges_set and 'B(11-20)' in ranges_set: adjacent_patterns['A+B'] += 1 if 'B(11-20)' in ranges_set and 'C(21-30)' in ranges_set: adjacent_patterns['B+C'] += 1 if 'C(21-30)' in ranges_set and 'D(31-40)' in ranges_set: adjacent_patterns['C+D'] += 1 if 'D(31-40)' in ranges_set and 'E(41-50)' in ranges_set: adjacent_patterns['D+E'] += 1 for pattern, count in adjacent_patterns.items(): percentage = (count / len(df)) * 100 print(f"Benachbarte Bereiche {pattern}: {count:3} Kombinationen ({percentage:4.1f}%)") # Export der Ergebnisse print(f"\n💾 EXPORT DER ERGEBNISSE:") print("="*30) # DataFrame für Z1-Z4 Kombinationen erstellen results_data = [] for i, row in df.iterrows(): ranges_z1_z4 = [get_range_for_number(row[col]) for col in z_columns_z1_z4] pattern = '|'.join(sorted(ranges_z1_z4)) diversity = len(set(ranges_z1_z4)) results_data.append({ 'datum': row['datum'], 'Z1': row['Z1'], 'Z2': row['Z2'], 'Z3': row['Z3'], 'Z4': row['Z4'], 'Z1_bereich': ranges_z1_z4[0], 'Z2_bereich': ranges_z1_z4[1], 'Z3_bereich': ranges_z1_z4[2], 'Z4_bereich': ranges_z1_z4[3], 'bereichsmuster': pattern, 'anzahl_bereiche': diversity }) results_df = pd.DataFrame(results_data) output_file = "/Users/sebastianfrohlich/Library/Mobile Documents/com~apple~CloudDocs/Jupyter Notebooks/Eurojackpot/bereichskombinationen_z1_z4.csv" results_df.to_csv(output_file, sep=';', index=False) print(f"✅ Detailergebnisse gespeichert: bereichskombinationen_z1_z4.csv") return pattern_counts_z1_z4, pattern_counts_all if __name__ == "__main__": analyze_range_combinations()