|
@@ -1,7 +1,11 @@
|
|
|
import numpy as np
|
|
|
import json
|
|
|
import matplotlib.pyplot as plt
|
|
|
+from collections import defaultdict
|
|
|
|
|
|
+# 设置Matplotlib的默认字体
|
|
|
+plt.rcParams['font.sans-serif'] = ['SimHei'] # 'SimHei' 是一种支持中文的字体
|
|
|
+plt.rcParams['axes.unicode_minus'] = False # 正确显示负号
|
|
|
# 假设数据文件名为 'betting_data.txt',每行为一个时间戳和JSON数据
|
|
|
file_path = '开奖记录.log'
|
|
|
|
|
@@ -83,6 +87,8 @@ def save_and_clear(key):
|
|
|
|
|
|
# 分析和绘图函数
|
|
|
def analyze_group_positions(round_info_list, group1, group2):
|
|
|
+ # 存储每个中奖选项组合在排序后赔付列表中的位置
|
|
|
+ combination_positions = []
|
|
|
# 存储每个中奖选项在排序后赔付列表中的位置
|
|
|
positions_group1 = []
|
|
|
positions_group2 = []
|
|
@@ -106,10 +112,26 @@ def analyze_group_positions(round_info_list, group1, group2):
|
|
|
if res in sorted_keys_group2:
|
|
|
positions_group2.append(sorted_keys_group2.index(res) + 1)
|
|
|
|
|
|
+ # 创建所有可能的组合并计算赔付总额
|
|
|
+ combinations_payouts = {}
|
|
|
+ for key1, payout1 in group1_payouts.items():
|
|
|
+ for key2, payout2 in group2_payouts.items():
|
|
|
+ combinations_payouts[(key1, key2)] = payout1 + payout2
|
|
|
+
|
|
|
+ # 对组合赔付总额进行排序
|
|
|
+ sorted_combinations = sorted(combinations_payouts.items(), key=lambda x: x[1])
|
|
|
+ sorted_combination_keys = [item[0] for item in sorted_combinations]
|
|
|
+
|
|
|
+ # 获取实际开奖结果的组合位置
|
|
|
+ winning_combination = tuple(info.result_option)
|
|
|
+ if winning_combination in sorted_combination_keys:
|
|
|
+ position = sorted_combination_keys.index(winning_combination) + 1
|
|
|
+ combination_positions.append(position)
|
|
|
+
|
|
|
# 绘制两个组的结果
|
|
|
plt.figure(figsize=(12, 6))
|
|
|
|
|
|
- plt.subplot(1, 2, 1)
|
|
|
+ plt.subplot(1, 3, 1)
|
|
|
# plt.hist(positions_group1, bins=len(group1), alpha=0.75, edgecolor='black', align='left', rwidth=0.5)
|
|
|
plt.hist(positions_group1, bins=np.arange(1, len(group1) + 2) - 0.5, alpha=0.75, edgecolor='black')
|
|
|
|
|
@@ -118,7 +140,7 @@ def analyze_group_positions(round_info_list, group1, group2):
|
|
|
plt.title('Frequency of Winning Options in Group 1')
|
|
|
plt.xticks(np.arange(1, len(group1) + 1))
|
|
|
|
|
|
- plt.subplot(1, 2, 2)
|
|
|
+ plt.subplot(1, 3, 2)
|
|
|
# plt.hist(positions_group2, bins=len(group2), alpha=0.75, edgecolor='black', align='left', rwidth=0.5)
|
|
|
plt.hist(positions_group2, bins=np.arange(1, len(group2) + 2) - 0.5, alpha=0.75, edgecolor='black')
|
|
|
|
|
@@ -127,9 +149,35 @@ def analyze_group_positions(round_info_list, group1, group2):
|
|
|
plt.title('Frequency of Winning Options in Group 2')
|
|
|
plt.xticks(np.arange(1, len(group2) + 1))
|
|
|
|
|
|
+ # 统计各个位置的频率
|
|
|
+ position_counts = defaultdict(int)
|
|
|
+ for pos in combination_positions:
|
|
|
+ position_counts[pos] += 1
|
|
|
+
|
|
|
+ # 统计各个位置的频率
|
|
|
+ total_positions = len(combination_positions)
|
|
|
+ # 绘制频率图
|
|
|
+ positions, frequencies = zip(*sorted(position_counts.items()))
|
|
|
+ plt.subplot(1, 3, 3)
|
|
|
+ plt.bar(positions, frequencies, color='skyblue')
|
|
|
+ plt.xlabel('Position in Combined Payout Sorting')
|
|
|
+ plt.ylabel('频率')
|
|
|
+ plt.title('奖金排名中获胜组合位置的频率')
|
|
|
+ plt.xticks(positions)
|
|
|
+
|
|
|
+ # 绘制频率图
|
|
|
+ frequencies_percentage = [f / total_positions * 100 for f in frequencies]
|
|
|
+ bars = plt.bar(positions, frequencies_percentage, color='skyblue')
|
|
|
+
|
|
|
+ # 在柱状图上添加百分比标签
|
|
|
+ for bar, freq in zip(bars, frequencies_percentage):
|
|
|
+ yval = bar.get_height()
|
|
|
+ plt.text(bar.get_x() + bar.get_width() / 2, yval, f'{freq:.2f}%', ha='center', va='bottom', fontsize=8)
|
|
|
+
|
|
|
plt.tight_layout()
|
|
|
plt.show()
|
|
|
|
|
|
+
|
|
|
def parse_data_from_file(_file_path):
|
|
|
clean_data(_file_path)
|
|
|
delete_wrong_data(_file_path)
|