优化随机数算法

main
roger 1 year ago
parent 3d9659c1b9
commit 8246393ace
  1. 8
      lottery_random.py
  2. 2
      real_index.py
  3. 12
      red_forecast.py

@ -2,10 +2,10 @@ import numpy
import datetime
def new_num(max_num, random_num):
def new_num(min_num, max_num, random_num):
num = {}
d = [i for i in range(1, max_num + 1)]
d = [i for i in range(min_num, max_num + 1)]
n = 100000
while n > 0:
@ -15,7 +15,7 @@ def new_num(max_num, random_num):
if r in num.keys():
num[r] += 1
else:
num[r] = 0
num[r] = 1
n -= 1
sorted_result = sorted(num.items(), key=lambda x: x[0])
@ -52,4 +52,4 @@ if __name__ == "__main__":
# print_time()
# print_num('red', get_num(new_num(33, 6), new_num(33, 6), 6))
# print_num('blue', get_num(new_num(16, 1), new_num(16, 1), 1))
print(new_num(33, 6)[0:6])
print(new_num(1, 11, 3))

@ -10,7 +10,7 @@ db = {
'database': 'lottery'
}
real_blue = ["01", "04", "09", "10", "20", "33"]
# real_blue = ["01", "04", "09", "10", "20", "33"]
def get_real_data():

@ -164,11 +164,15 @@ def get_random_index():
random_low = random.randint(1, 6 - random_high)
random_middle = 6 - random_high - random_low
print('分布区间(高概率区,中概率区,低概率区):', random_high, random_middle, random_low)
high_red_index_list = [n[0] - 1 for n in new_num(11, random_high)[0:random_high]]
middle_red_index_list = [n[0] - 1 + 10 for n in new_num(11, random_middle)[0:random_middle]]
low_red_index_list = [n[0] - 1 + 20 for n in new_num(11, random_low)[0:random_low]]
high_red_index_list = [(n[0]-1) for n in new_num(1, 11, random_high)[0:random_high]]
middle_red_index_list = [(n[0]-1) for n in new_num(12, 22, random_middle)[0:random_middle]]
low_red_index_list = [(n[0]-1) for n in new_num(23, 33, random_low)[0:random_low]]
print(high_red_index_list)
print(middle_red_index_list)
print(low_red_index_list)
red_index_list = sorted(high_red_index_list + middle_red_index_list + low_red_index_list)
# print(red_index_list)
print(f"排序后结果")
print(red_index_list)
return red_index_list

Loading…
Cancel
Save