前提准备:利用sql筛选出每个球出现概率最高的前5个数

原理:先爬出所有的历史数据,然后模拟摇奖机出球的机制并大量模拟计算,直到出现列表中的某一个数后即停

注意事项:由于计算过程数据量很大,需要加入内存释放的操作

成果:目前博主最好记录是中了3红1蓝,适合学习交流使用,信则有

#coding=utf-8
import random
import time
import gc
import datetime
from collections import Counter
try:
dt = datetime.datetime.now()
time.sleep(1)
print u'程序启动时间:'+dt.strftime('%Y-%m-%d %H:%M:%S')
time.sleep(2)
print u'程序正在计算......'
real_red_1 = [1, 2, 3, 4, 5]
real_red_2 = [7, 8, 6, 9, 5]
real_red_3 = [14, 11, 13, 16, 12]
real_red_4 = [20, 17, 22, 23, 18]
real_red_5 = [26, 27, 25, 28, 24]
real_red_6 = [32, 33, 31, 30, 29]
real_blue = [9, 12, 11, 14, 6,13,7,15]
def num_red_1():
i = 0
numlist_1 = []
numlist_2 = []
numlist_3 = []
numlist_4 = []
numlist_5 = []
while i < 10000:
i = i + 1
numlist_1.append(random.randint(1, 33))
gc.collect()
numlist_2.append(random.randint(1, 33))
gc.collect()
numlist_3.append(random.randint(1, 33))
gc.collect()
numlist_4.append(random.randint(1, 33))
gc.collect()
numlist_5.append(random.randint(1, 33))
global numlist
numlist = numlist_1 + numlist_2 + numlist_3 + numlist_4 + numlist_5
numpercent = {}
for d in set(numlist):
numpercent[numlist.count(d)] = d
for e in reversed(sorted(numpercent.keys())[-1:]):
return numpercent[e]
while True:
for i in range(10000):
num_red_1()
bingonum_red_1 = num_red_1()
if bingonum_red_1 not in real_red_1:
continue
c = Counter(numlist)
# print c[bingonum_red_1]
if bingonum_red_1 == 1:
numberA = c[bingonum_red_1]/float(50000)
numberB = 384/float(2004)
# print numberA
# print numberB
# print '%.2f%%'%(numberA / numberB*100)
print u'一号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_1) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_1 == 2:
numberA = c[bingonum_red_1]/float(50000)
numberB = 307/float(2004)
print u'一号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_1) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_1 == 3:
numberA = c[bingonum_red_1]/float(50000)
numberB = 255/float(2004)
print u'一号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_1) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_1 == 4:
numberA = c[bingonum_red_1]/float(50000)
numberB = 209/float(2004)
print u'一号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_1) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
else:
numberA = c[bingonum_red_1]/float(50000)
numberB = 175/float(2004)
print u'一号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_1) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
break
break
time.sleep(5)
def num_red_2():
i = 0
numlist_1 = []
numlist_2 = []
numlist_3 = []
numlist_4 = []
numlist_5 = []
while i < 10000:
i = i + 1
numlist_1.append(random.randint(1, 33))
gc.collect()
numlist_2.append(random.randint(1, 33))
gc.collect()
numlist_3.append(random.randint(1, 33))
gc.collect()
numlist_4.append(random.randint(1, 33))
gc.collect()
numlist_5.append(random.randint(1, 33))
global numlist
numlist = numlist_1 + numlist_2 + numlist_3 + numlist_4 + numlist_5
numpercent = {}
for d in set(numlist):
numpercent[numlist.count(d)] = d
for e in reversed(sorted(numpercent.keys())[-1:]):
return numpercent[e]
while True:
for i in range(10000):
num_red_2()
bingonum_red_2 = num_red_2()
if bingonum_red_2 not in real_red_2:
continue
c = Counter(numlist)
if bingonum_red_2 == 7:
numberA = c[bingonum_red_2]/float(50000)
numberB = 181/float(2004)
print u'二号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_2) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_2 == 8:
numberA = c[bingonum_red_2]/float(50000)
numberB = 168/float(2004)
print u'二号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_2) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_2 == 6:
numberA = c[bingonum_red_2]/float(50000)
numberB = 160/float(2004)
print u'二号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_2) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_2 == 9:
numberA = c[bingonum_red_2]/float(50000)
numberB = 140/float(2004)
print u'二号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_2) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
else:
numberA = c[bingonum_red_2]/float(50000)
numberB = 140/float(2004)
print u'二号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_2) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
break
break
time.sleep(5)
def num_red_3():
i = 0
numlist_1 = []
numlist_2 = []
numlist_3 = []
numlist_4 = []
numlist_5 = []
while i < 10000:
i = i + 1
numlist_1.append(random.randint(1, 33))
gc.collect()
numlist_2.append(random.randint(1, 33))
gc.collect()
numlist_3.append(random.randint(1, 33))
gc.collect()
numlist_4.append(random.randint(1, 33))
gc.collect()
numlist_5.append(random.randint(1, 33))
global numlist
numlist = numlist_1 + numlist_2 + numlist_3 + numlist_4 + numlist_5
numpercent = {}
for d in set(numlist):
numpercent[numlist.count(d)] = d
for e in reversed(sorted(numpercent.keys())[-1:]):
return numpercent[e]
while True:
for i in range(10000):
num_red_3()
bingonum_red_3 = num_red_3()
if bingonum_red_3 not in real_red_3:
continue
c = Counter(numlist)
if bingonum_red_3 == 14:
numberA = c[bingonum_red_3]/float(50000)
numberB = 147/float(2004)
print u'三号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_3) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_3 == 11:
numberA = c[bingonum_red_3]/float(50000)
numberB = 136/float(2004)
print u'三号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_3) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_3 == 13:
numberA = c[bingonum_red_3]/float(50000)
numberB = 129/float(2004)
print u'三号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_3) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_3 == 16:
numberA = c[bingonum_red_3]/float(50000)
numberB = 128/float(2004)
print u'三号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_3) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
else:
numberA = c[bingonum_red_3]/float(50000)
numberB = 125/float(2004)
print u'三号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_3) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
break
break
time.sleep(5)
def num_red_4():
i = 0
numlist_1 = []
numlist_2 = []
numlist_3 = []
numlist_4 = []
numlist_5 = []
while i < 10000:
i = i + 1
numlist_1.append(random.randint(1, 33))
gc.collect()
numlist_2.append(random.randint(1, 33))
gc.collect()
numlist_3.append(random.randint(1, 33))
gc.collect()
numlist_4.append(random.randint(1, 33))
gc.collect()
numlist_5.append(random.randint(1, 33))
global numlist
numlist = numlist_1 + numlist_2 + numlist_3 + numlist_4 + numlist_5
numpercent = {}
for d in set(numlist):
numpercent[numlist.count(d)] = d
for e in reversed(sorted(numpercent.keys())[-1:]):
return numpercent[e]
while True:
for i in range(10000):
num_red_4()
bingonum_red_4 = num_red_4()
if bingonum_red_4 not in real_red_4:
continue
c = Counter(numlist)
if bingonum_red_4 == 20:
numberA = c[bingonum_red_4]/float(50000)
numberB = 147/float(2004)
print u'四号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_4) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_4 == 17:
numberA = c[bingonum_red_4]/float(50000)
numberB = 146/float(2004)
print u'四号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_4) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_4 == 22:
numberA = c[bingonum_red_4]/float(50000)
numberB = 144/float(2004)
print u'四号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_4) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_4 == 23:
numberA = c[bingonum_red_4]/float(50000)
numberB = 132/float(2004)
print u'四号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_4) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
else:
numberA = c[bingonum_red_4]/float(50000)
numberB = 129/float(2004)
print u'四号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_4) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
break
break
time.sleep(5)
def num_red_5():
i = 0
numlist_1 = []
numlist_2 = []
numlist_3 = []
numlist_4 = []
numlist_5 = []
while i < 10000:
i = i + 1
numlist_1.append(random.randint(1, 33))
gc.collect()
numlist_2.append(random.randint(1, 33))
gc.collect()
numlist_3.append(random.randint(1, 33))
gc.collect()
numlist_4.append(random.randint(1, 33))
gc.collect()
numlist_5.append(random.randint(1, 33))
global numlist
numlist = numlist_1 + numlist_2 + numlist_3 + numlist_4 + numlist_5
numpercent = {}
for d in set(numlist):
numpercent[numlist.count(d)] = d
for e in reversed(sorted(numpercent.keys())[-1:]):
return numpercent[e]
while True:
for i in range(10000):
num_red_5()
bingonum_red_5 = num_red_5()
if bingonum_red_5 not in real_red_5:
continue
c = Counter(numlist)
if bingonum_red_5 == 26:
numberA = c[bingonum_red_5]/float(50000)
numberB = 173/float(2004)
print u'五号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_5) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_5 == 27:
numberA = c[bingonum_red_5]/float(50000)
numberB = 167/float(2004)
print u'五号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_5) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_5 == 25:
numberA = c[bingonum_red_5]/float(50000)
numberB = 164/float(2004)
print u'五号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_5) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_5 == 28:
numberA = c[bingonum_red_5]/float(50000)
numberB = 160/float(2004)
print u'五号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_5) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
else:
numberA = c[bingonum_red_5]/float(50000)
numberB = 133/float(2004)
print u'五号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_5) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
break
break
time.sleep(5)
def num_red_6():
i = 0
numlist_1 = []
numlist_2 = []
numlist_3 = []
numlist_4 = []
numlist_5 = []
while i < 10000:
i = i + 1
numlist_1.append(random.randint(1, 33))
gc.collect()
numlist_2.append(random.randint(1, 33))
gc.collect()
numlist_3.append(random.randint(1, 33))
gc.collect()
numlist_4.append(random.randint(1, 33))
gc.collect()
numlist_5.append(random.randint(1, 33))
global numlist
numlist = numlist_1 + numlist_2 + numlist_3 + numlist_4 + numlist_5
numpercent = {}
for d in set(numlist):
numpercent[numlist.count(d)] = d
for e in reversed(sorted(numpercent.keys())[-1:]):
return numpercent[e]
while True:
for i in range(10000):
num_red_6()
bingonum_red_6 = num_red_6()
if bingonum_red_6 not in real_red_6:
continue
c = Counter(numlist)
if bingonum_red_6 == 32:
numberA = c[bingonum_red_6]/float(50000)
numberB = 309/float(2004)
print u'六号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_6) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_6 == 33:
numberA = c[bingonum_red_6]/float(50000)
numberB = 307/float(2004)
print u'六号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_6) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_6 == 31:
numberA = c[bingonum_red_6]/float(50000)
numberB = 249/float(2004)
print u'六号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_6) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_red_6 == 30:
numberA = c[bingonum_red_6]/float(50000)
numberB = 221/float(2004)
print u'六号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_6) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
else:
numberA = c[bingonum_red_6]/float(50000)
numberB = 202/float(2004)
print u'六号红球预测完成' + ' ' + u'号码:' + str(bingonum_red_6) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
break
break
time.sleep(5)
def num_blue():
i = 0
numlist_1 = []
numlist_2 = []
numlist_3 = []
numlist_4 = []
numlist_5 = []
while i < 10000:
i = i + 1
numlist_1.append(random.randint(1, 16))
gc.collect()
numlist_2.append(random.randint(1, 16))
gc.collect()
numlist_3.append(random.randint(1, 16))
gc.collect()
numlist_4.append(random.randint(1, 16))
gc.collect()
numlist_5.append(random.randint(1, 16))
global numlist
numlist = numlist_1 + numlist_2 + numlist_3 + numlist_4 + numlist_5
numpercent = {}
for d in set(numlist):
numpercent[numlist.count(d)] = d
for e in reversed(sorted(numpercent.keys())[-1:]):
return numpercent[e]
while True:
for i in range(10000):
num_blue()
bingonum_blue = num_blue()
if bingonum_blue not in real_blue:
continue
c = Counter(numlist)
if bingonum_blue == 9:
numberA = c[bingonum_blue]/float(50000)
numberB = 140/float(2004)
print u'蓝球预测完成' + ' ' + u'号码:' + str(bingonum_blue) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_blue == 12:
numberA = c[bingonum_blue]/float(50000)
numberB = 136/float(2004)
print u'蓝球预测完成' + ' ' + u'号码:' + str(bingonum_blue) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_blue == 11:
numberA = c[bingonum_blue]/float(50000)
numberB = 135/float(2004)
print u'蓝球预测完成' + ' ' + u'号码:' + str(bingonum_blue) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_blue == 14:
numberA = c[bingonum_blue]/float(50000)
numberB = 130/float(2004)
print u'蓝球预测完成' + ' ' + u'号码:' + str(bingonum_blue) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_blue == 6:
numberA = c[bingonum_blue]/float(50000)
numberB = 129/float(2004)
print u'蓝球预测完成' + ' ' + u'号码:' + str(bingonum_blue) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_blue == 13:
numberA = c[bingonum_blue]/float(50000)
numberB = 129/float(2004)
print u'蓝球预测完成' + ' ' + u'号码:' + str(bingonum_blue) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
elif bingonum_blue == 7:
numberA = c[bingonum_blue]/float(50000)
numberB = 128/float(2004)
print u'蓝球预测完成' + ' ' + u'号码:' + str(bingonum_blue) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
else:
numberA = c[bingonum_blue]/float(50000)
numberB = 128/float(2004)
print u'蓝球预测完成' + ' ' + u'号码:' + str(bingonum_blue) + ' ' + u'中奖概率' + str(
'%.2f%%' % (numberB*(1+numberA)*100))
break
break
finally:
raw_input()

  

【原创】python基于大数据现实双色球预测的更多相关文章

  1. Python/Numpy大数据编程经验

    Python/Numpy大数据编程经验 1.边处理边保存数据,不要处理完了一次性保存.不然程序跑了几小时甚至几天后挂了,就啥也没有了.即使部分结果不能实用,也可以分析程序流程的问题或者数据的特点.   ...

  2. H2O是开源基于大数据的机器学习库包

    H2O是开源基于大数据的机器学习库包 H2O能够让Hadoop做数学,H2O是基于大数据的 统计分析 机器学习和数学库包,让用户基于核心的数学积木搭建应用块代码,采取类似R语言 Excel或JSON等 ...

  3. 黑马基础阶段测试题:创建一个存储字符串的集合list,向list中添加以下字符串:”C++”、”Java”、” Python”、”大数据与云计算”。遍历集合,将长度小于5的字符串从集合中删除,删除成功后,打印集合中的所有元素

    package com.swift; import java.util.ArrayList; import java.util.List; import java.util.ListIterator; ...

  4. 【Python开发】Python 适合大数据量的处理吗?

    Python 适合大数据量的处理吗? python 能处理数据库中百万行级的数据吗? 处理大规模数据时有那些常用的python库,他们有什么优缺点?适用范围如何? 需要澄清两点之后才可以比较全面的看这 ...

  5. 为什么说Python 是大数据全栈式开发语言

    欢迎大家访问我的个人网站<刘江的博客和教程>:www.liujiangblog.com 主要分享Python 及Django教程以及相关的博客 交流QQ群:453131687 原文链接 h ...

  6. 大数据征信的应用和启示:ZestFinance的基于大数据的信用评估技术

    http://www.d1net.com/bigdata/news/325426.html 2014年11月,本文作者有机会和ZestFinance的创始人和首席执行官梅里尔(Douglas C.Me ...

  7. python学习--大数据与科学计算第三方库简介

    大数据与科学计算  库名称 简介 pycuda/opencl GPU高性能并发计算 Pandas python实现的类似R语言的数据统计.分析平台.基于NumPy和Matplotlib开发的,主要用于 ...

  8. 深度剖析 | 基于大数据架构的BI应用

    说起互联网.电商的数据分析,更多的是谈应用案例,如何去实践数据化管理运营.而这里,我们要从技术角度分享关于数据的技术架构干货,如何应用BI. 原文是云猴网BI总经理王卫东在帆软大数据上的演讲,以下是整 ...

  9. 菜鸟学python之大数据的初认识

    这次作业的要求来自于:https://edu.cnblogs.com/campus/gzcc/GZCC-16SE1/homework/2639 1.这些分析所采用数据来源是什么? 国家数据库:中国铁路 ...

随机推荐

  1. 用 eclipse 创建一个简单的 meaven spring springMvc mybatis 项目

    下面是整体步骤: 1: 先创建一个Maven 项目: 选择跳过骨架: 因为要搭建的是 web 项目  所以这个地方选择 war 包; 点击完成 这样就完成 Maven项目的搭建: 接下俩 先把 Mav ...

  2. MapReduce-实践1

      MR进阶实践1:  -file 分发多个文件 [-file 适合场景]分发文件在本地,小文件 -file分发原理         run.sh文件: 通过多个-file, 将多个本地文件分发到Ha ...

  3. C++类与对象(05)

    类是具有惟一标识符的实体:在类中声明的任何成员不能使用extern.auto和register关键字进行修饰:类中声明的变量属于该类,在某些情况下,变量也可以被该类的不同实例所共享. 访问权限用于控制 ...

  4. maven基本基础知识及命令学习-1

    Maven概述:Maven是很有效的项目管理工具,maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目构建.报告和文档的软件项目管理工具.统一管理环境,架包等. 一 maven下载 ...

  5. HDU1150 Machine Schedule(二分图最大匹配、最小点覆盖)

    As we all know, machine scheduling is a very classical problem in computer science and has been stud ...

  6. 暑假练习赛 007 C - OCR

    C - OCR Description standard input/outputStatements Optical Character Recognition (OCR) is one of th ...

  7. nginx服务部署 说明

    第1章 常用的软件 1.1 常用来提供静态服务的软件   Apache :这是中小型Web服务的主流,Web服务器中的老大哥,   Nginx :大型网站Web服务的主流,曾经Web服务器中的初生牛犊 ...

  8. CentOS6.8通过yum安装MySQL5.7

    Centos6.8通过yum安装mysql5.7 1.安装mysql的yum源 a.下载配置mysql的yum源的rpm包 根据上面3张图片中的操作下载下来的rpm文件可以通过如下命令获取: wget ...

  9. vue初级学习--组件的使用(自定义组件)

    一.导语 突然冒出四个字,分即是合,嗯,优点道理....................... 二.正文 在搞的仿淘宝demo,之前加入购物车是与商品详情一块的,今天把它单独拆出来,复用性高点,那这样 ...

  10. 动态代理:JDK动态代理和CGLIB代理的区别

    代理模式:代理类和被代理类实现共同的接口(或继承),代理类中存有指向被代理类的索引,实际执行时通过调用代理类的方法.实际执行的是被代理类的方法. 而AOP,是通过动态代理实现的. 一.简单来说: JD ...