練習(xí):號(hào)碼出現(xiàn)有規(guī)律嗎?

剛開始學(xué)習(xí)數(shù)據(jù)分析,正好發(fā)現(xiàn)這是個(gè)非常不錯(cuò)的例子,可以嘗試看一下中獎(jiǎng)率是否有規(guī)律可循。

結(jié)論:

簡(jiǎn)單來看,各數(shù)字頻率并沒有想象中那么一致的,有個(gè)別幾個(gè)數(shù)字會(huì)比其他的數(shù)字高,順序上在長(zhǎng)期或短期都一樣,但短期各數(shù)頻率差別更大。

未來希望可以用更復(fù)雜的統(tǒng)計(jì)方法和技術(shù)進(jìn)行深入分析,然后可以嘗試配合玩法和一些組合投入方式,或許可以讓期望收益變得不錯(cuò)。

一、獲取10年的出號(hào)情況

爬取2009年到~2019年12月內(nèi)所有的出號(hào)情況,清理下空值和格式,把index改為時(shí)間序列方便接下來處理

image

這里用的是selenium和lxml,本來想用requestsHTML,但是有些東西用不了,只好用慢一點(diǎn)的。

from selenium import webdriver
from lxml import etree
import pandas as pd
import numpy as np

#url
url = 'https://datachart.500.com/ssq/history/history.shtml'
#輸入時(shí)間周期,請(qǐng)求數(shù)據(jù)
start = '09151'
end = '19151'
driver = webdriver.Chrome(executable_path="F:\chromedriver")
driver.get(url)
driver.find_element_by_xpath('//*[@id="start"]').clear()
driver.find_element_by_xpath('//*[@id="start"]').send_keys(start)
driver.find_element_by_xpath('//*[@id="end"]').clear()
driver.find_element_by_xpath('//*[@id="end"]').send_keys(end)

driver.find_element_by_xpath('//*[@id="container"]/div/table/tbody/tr[1]/td/div/div[1]/div/table/tbody/tr/td[2]/img').click()
html_str = driver.execute_script("return document.documentElement.outerHTML")

#分析頁(yè)面
DATA = []
htmlE = etree.HTML(html_str)
trs = htmlE.xpath('//*[@id="tdata"]/tr')
for tr in trs:
    num = tr.xpath('.//td/text()')
    DATA.append(num)

#轉(zhuǎn)存dataframe,保存數(shù)據(jù)
col = ['期號(hào)','r1','r2','r3','r4','r5','r6','b1','hsd','獎(jiǎng)池獎(jiǎng)金','一等獎(jiǎng)_注數(shù)','一等獎(jiǎng)_獎(jiǎng)金','二等獎(jiǎng)_注數(shù)','二等獎(jiǎng)_獎(jiǎng)金','總投注','date']
df = pd.DataFrame(DATA,columns=col)
df.set_index(["date"], inplace=True)#設(shè)置index為自身的日期列
del df['hsd']

#去掉多余的,
def repl(st):
    st = str(st)
    return st.replace(',','')
s = df.applymap(repl)
s.to_csv('E:\data\lottery_data.txt',sep=",",encoding='utf-8')

二、一二等獎(jiǎng)的每期中獎(jiǎng)量變化相同

image

可以看出,10年內(nèi)一等獎(jiǎng)和二等獎(jiǎng)中獎(jiǎng)的注數(shù)是一起變化的,中獎(jiǎng)的注數(shù)10年來很穩(wěn)定,沒有升高或者降低,起伏的原因不知道是玩法的調(diào)整還是普通的周期變化,再接下來就得看一下號(hào)碼的情況了。

import pandasas pd
import numpyas np
import matplotlib.pyplotas plt

#顯示中文
plt.rcParams['font.sans-serif'] = ['SimHei']# 用來正常顯示中文標(biāo)簽
plt.rcParams['axes.unicode_minus'] =False  # 用來正常顯示負(fù)號(hào)

#導(dǎo)入
df = pd.read_csv('E:\data\lottery_data.txt',encoding='utf-8')
pd.set_option('display.max_columns', None)

#index變?yōu)闀r(shí)間序列
df.index = pd.to_datetime(df['date'])
print(df.head())

#提取數(shù)據(jù),降維
a = df['一等獎(jiǎng)_注數(shù)'].resample('M').sum()
s = df['二等獎(jiǎng)_注數(shù)'].resample('M').sum()/10

#設(shè)置各圖
fig = plt.figure(num=1,figsize=(10,3))
ax1=fig.add_subplot(1,1,1)
ax1.plot(a,label='一等獎(jiǎng)')
ax2=fig.add_subplot(1,1,1)
ax2.plot(s,label='二等獎(jiǎng)')

#設(shè)定圖例和標(biāo)題

plt.title('2009~2019 中獎(jiǎng)注數(shù)頻率分布 組寬:月')
plt.legend(loc=0)

#保存

plt.savefig(r'C:\Users\ryan\Desktop\新建文件夾\2.png')
plt.show()

三、短期內(nèi)部分?jǐn)?shù)字出現(xiàn)頻率是其他數(shù)字的兩倍

分別從10年和最近6個(gè)月來看一下紅球和藍(lán)球的情況,由于雙色球不看號(hào)碼順序,所以位數(shù)暫時(shí)忽略。從圖里可以明顯看出短期內(nèi)的頻率差別更大長(zhǎng)期雖然較為穩(wěn)定,但是有些數(shù)字的分位沒什么大變動(dòng)。

image
#計(jì)算
a1 = df[['r1','r2','r3','r4','r5','r6']].copy().apply(pd.value_counts)
a1 = a1.sum(axis=1)
a1 = a1.sort_values(ascending=False)
a2 = df['b1'].copy().value_counts()

df.index = pd.to_datetime(df['date'])
a3 = df[['r1','r2','r3','r4','r5','r6']].truncate(after='2019-06-15')
a3 = a3.apply(pd.value_counts)
a3 = a3.sum(axis=1)
a3 = a3.sort_values(ascending=False)

a4 = df['b1'].truncate(after='2019-06-15').value_counts()
#設(shè)定圖表
fig = plt.figure(num=1,figsize=(14,8))

ax1 = fig.add_subplot(2,2,1)
a1.plot(kind='bar',color='red',alpha=0.8)
plt.title('10年 紅色數(shù)字頻數(shù)分布')

ax2 = fig.add_subplot(2,2,2)
a2.plot(kind='bar',alpha=0.8)
plt.title('10年 藍(lán)色數(shù)字頻數(shù)分布')

ax3 = fig.add_subplot(2,2,3)
a3.plot(kind='bar',color='red',alpha=0.8)
plt.title('最近6個(gè)月 紅色數(shù)字頻數(shù)分布')

ax4 = fig.add_subplot(2,2,4)
a4.plot(kind='bar',alpha=0.8)
plt.title('最近6個(gè)月 藍(lán)色數(shù)字頻數(shù)分布')
plt.savefig(r'C:\Users\ryan\Desktop\新建文件夾\3.png')
plt.show()

結(jié):目前掌握的統(tǒng)計(jì)方法和技術(shù)太少,也沒有特別完整的框架流程,還需繼續(xù)學(xué)習(xí)。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • “歷史是季節(jié)性的,凜冬將至”。 這應(yīng)該是《權(quán)力的游戲》中那個(gè)魔幻世界的運(yùn)行規(guī)則。 孫立平的新作《班農(nóng)主義是理解美國(guó)...
    唐古拉樹閱讀 459評(píng)論 0 0
  • 昨天有人說: 三過家門而不入, 就是說遇到自己喜歡人或事 ,不想回家 ,而一天中三次經(jīng)過家門卻沒有一點(diǎn)想回去的意思...
    I向陽(yáng)花芬芳閱讀 377評(píng)論 0 2
  • 跌跌撞撞,也總算上了大學(xué)了。大學(xué)生活,如所聞那樣,期待的那樣,自由輕松,但很快會(huì)膩。人吶,還是要找點(diǎn)事情做,甚至要...
    愛若r閱讀 231評(píng)論 0 0

友情鏈接更多精彩內(nèi)容