ç®±æ ¹é§ ä¼ã§åªåãã確çãã¨ã³ããªã¼æã®ã¿ã¤ã ãç¨ãã¦äºæ¸¬ãã¦ã¿ã
ã¯ããã«
ç®±æ ¹é§ ä¼ã¯å¥½ãã§å²ã¨æ¯å¹´è¦ã¦ããã®ã§ããã ãã©ã½ã³ç³»ã®ç«¶æã£ã¦ããã©ã¼ãã³ã¹ã®åæ£ã対人競æã¨æ¯è¼ããã¨å°ãããªããããå®ã¯äºåã®æ å ±ããçµæãäºæ¸¬ãããã¨ãæ¯è¼ç容æãªããããªããï¼ã¨ããçåãæµ®ããã ã®ã§ãå大å¦ãåªåãã確çãåºãã¦ã¿ããã¨ã«ãã¾ããã
æ¹éã¨ãã¦ã¯ãç®±æ ¹é§ ä¼ã«åºå ´ããåæ ¡ã®ããã10人ã®10000må¹³åã¿ã¤ã ããç®±æ ¹é§ ä¼ã®äºæ¸¬ã¿ã¤ã ã®åå¸ãç®åºãã ç®åºããäºæ¸¬åå¸ãç¨ãã¦åæ ¡ãåªåãã確çãäºæ¸¬ãã¾ãã
ãã¼ã¿ã®åéã»ç¢ºèª
åå¹´ã®10000mã®ã¿ã¤ã ã¨ç®±æ ¹é§ ä¼ã®ç·åã¿ã¤ã ã«ã¤ãã¦ã¯ä»¥ä¸ã®ãµã¤ãåèã«ããã¦ããã ãã¾ããã
ä¸è¨ã®ãµã¤ããã2013-2018å¹´ã®éå»ï¼å¹´åã®ç®±æ ¹é§ ä¼ã¨ã³ããªã¼æã®åæ ¡ä¸ä½10人ã®10000må¹³åã¿ã¤ã ãåå¾ãã ï¼æ¬¡å ããããããå³ã以ä¸ã«ãªãã¾ãã
横軸ã10000mã®å¹³åã¿ã¤ã ã縦軸ãç®±æ ¹é§ ä¼ã®ç·åã¿ã¤ã ã§ããåä½ã¯ç§ã«ç´ãã¦ãã¾ãã 2ã¤ã®å¤æ°ã«ã¯æ£ã®ç¸é¢ãããã¾ããããããªãã«ã°ãã¤ããããããã§ãã
ã¢ãã«ã®æ§ç¯
ä»åæ±ãããã®ã¯äºæ¸¬å¤ã§ã¯ãªãäºæ¸¬åå¸ãªã®ã§ãæ©æ¢°å¦ç¿ã§ã¯ãªãçµ±è¨ã¢ããªã³ã°ã®ææ³ãç¨ãã¾ãã å ·ä½çã«ã¯ãããçµ±è¨ã¢ãã«ãä½æãããã®ã¢ãã«ã®ãã©ã¡ã¼ã¿ãæ¨å®ããããã«Stanã§MCMCãè¡ãã¾ãã
çµ±è¨ã¢ããªã³ã°ã®è©³ãã話ã¯å²æãã¾ããã Stanã¨Rã§ãã¤ãºçµ±è¨ã¢ããªã³ã° ã¨ããããããããã¿ããã§ãï¼ã¾ã èªäºãã¦ã¾ãããããï¼
ä»åã¯ã¢ãã«ã以ä¸ã®ããã«ããã¾ããã
], )
yãç®±æ ¹é§ ä¼ã®ç·åã¿ã¤ã ãX[N]ãNãµã³ãã«ç®ã®10000mã¿ã¤ã ã¨ãã yãå¹³å]ãåæ£ã®æ£è¦åå¸ã§ããã¨ä»®å®ãã¦ãã¾ãã stanãç¨ãã¦ãã©ã¡ã¼ã¿ã¨ã®æ¨å®ãè¡ãã¾ãã
stanã®ã³ã¼ãã¯ä»¥ä¸ã®ããã«ãªãã¾ããRã¯ä¸å¾æãªã®ã§pystanã使ã£ã¦ãã¾ãã
model = """ data { int<lower=0> N; real X[N]; real Y[N]; } parameters { real a; real<lower=0> sigma; } model { for (i in 1:N) Y[i] ~ normal(a*X[N], sigma); } """
stanãå®è¡ãã¾ãã
stan_data = {'N': len(x), 'X':x, 'Y': y} sm = pystan.StanModel(model_code=model) fit = sm.sampling(data=stan_data, iter=10000, chains=3)
çµæã¯ä¸è¨ã®ããã«ãªãã¾ããã rhatã¯ã©ã®å¤ã1.0ãªã®ã§åæãã¦ãã¾ããã
åçã®ç®åº
åç« ã§å°åºãããã©ã¡ã¼ã¿ã使ã£ã¦åæ ¡ã®åçãç®åºãã¦ã¿ã¾ãã 2019å¹´ã®10000må¹³åã¿ã¤ã ã¨å ã»ã©æ¨å®ãããã©ã¡ã¼ã¿ãç¨ãã¦åæ ¡ã®äºæ¸¬åå¸ãä½æãã ããããã©ã³ãã ãµã³ããªã³ã°ã10000åè¡ããåªåãã確çãäºæ¸¬ãã¾ãã
import numpy as np from numpy.random import * #試è¡åæ° num=10000 #空箱 arr=np.zeros((num,len(time_10000m))) #ã©ã³ãã ãµã³ããªã³ã°ã«ããåæ ¡ã®äºæ¸¬ã¿ã¤ã ãåºå for n in range(num): for order, ti in enumerate(time_10000m): arr[n,order]=normal(22.93*ti,623.67) #ãã©ã¡ã¼ã¿ã¯å ã»ã©æ±ããå¤ #å試è¡ã®ãããã®å¤§å¦ãã«ã¦ã³ããå²åã« prob=pd.DataFrame(pd.Series(arr.argmin(axis=1)).value_counts()/num) result=df2018.join(prob) result=result.sort_values(by=0,ascending=False) #ã°ã©ãç¨ plt.figure(figsize=(12,8)) plt.bar(result["大å¦å"],result[0]) plt.xticks(rotation=30) plt.show()
ä»åã®ä»®å®ã®ç½®ãæ¹ã ã¨åªåãã確çã¯éå±±å¦é¢å¤§ã19%ãæ±æµ·å¤§ã12.5%ãé§æ²¢å¤§ãå¸äº¬å¤§ã9%ãæ±æ´å¤§ã7ï¼ ã¨ããçµæã«ãªãã¾ããã (å®éã®é ä½ã¯1ä½ï¼æ±æµ·å¤§ã2ä½ï¼éå±±å¦é¢å¤§ã3ä½ï¼æ±æ´å¤§ã4ä½ï¼é§æ²¢å¤§ã5ä½ï¼å¸äº¬å¤§)
èå¯
å人çã«ã¯10000må¹³åã¿ã¤ã ãä¸ä½ã®ãã¼ã ã®åªå確çã¯ããå°ãé«ããä¸ä½ã®ãã¼ã ã®åªå確çã¯ããå°ãä½ãã¤ã¡ã¼ã¸ãªã®ã§ãå®éããäºæ¸¬åå¸ãåºãã£ã¦ãã¾ã£ã¦ããããªã¨ããæ°ããã¾ãã åå ã¨ãã¦ã¯ãä»åã¯ä¸ä½10人ã®10000mã®å¹³åã¿ã¤ã ã®ã¿ããç®±æ ¹é§ ä¼ã®ç·åã¿ã¤ã ãäºæ¸¬ããã¨ããçµæ§å¤§éæãªä»®å®ã§è¡ã£ãããã ã¨èããããã®ã§ã天åãé¸æ層ã®åã¿ãèµ°è ã®å¦å¹´åå¸çãã¢ãã«ã«è¿½å ãããã¨ã§ãããå°ãåæ£ã®å°ããäºæ¸¬ãæå¾ ã§ããããªã¨æãã¾ãã
使ç¨ããã³ã¼ãã¯ä»¥ä¸ã«ãªãã¾ãã
https://github.com/rmizuta3/hakone_ekiden