2015年のシカゴマラソンについて計算する
2015年10月11日に開催された2015年シカゴマラソンには45,000のランナーが集まった.37,000名以上のランナーが完走し,各ランナーのパフォーマンスの詳細は注意深く記録された.ここでは,このデータを含むカスタム実体ストアを使ってランナーとそのパフォーマンスの特徴を調べ,可視化する.
ResourceObjectからマラソンのEntityStoreをロードする.
In[1]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_180.png)
marathonEntityStore = ResourceData[
ResourceObject[
Association[
"Name" -> "2015 Chicago Marathon Data",
"UUID" -> "7dc77972-cfc3-48dc-8d08-0292c6d2a929",
"ResourceType" -> "DataResource", "Version" -> "1.0.0",
"Description" -> "2015 Chicago Marathon participant data",
"ContentSize" -> Quantity[1990.2215919999999`, "Megabytes"],
"ContentElements" -> {"Content"}]]]
Out[1]=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_129.png)
このセッション用にストアを登録する.
In[2]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_181.png)
PrependTo[$EntityStores, marathonEntityStore];
ランナー総数と,隠的に定義された実体クラスを使って,男性の人数と女性の人数を取り出す.
In[3]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_182.png)
EntityValue["ChicagoMarathon2015", "EntityCount"]
Out[3]=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_130.png)
In[4]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_183.png)
Table[EntityValue[
EntityClass["ChicagoMarathon2015", "Gender" -> gender],
"EntityCount"], {gender, {Entity["Gender", "Male"],
Entity["Gender", "Female"]}}]
Out[4]=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_131.png)
5人のランナーをランダムに選ぶ.
In[5]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_184.png)
RandomEntity["ChicagoMarathon2015", 5]
Out[5]=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_132.png)
特定のランナーについて保存された特性を見る.
In[6]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_185.png)
Entity["ChicagoMarathon2015", "Runner145"]["PropertyAssociation"]
ランナーの国籍の合計を抽出し,参加ランナーが多かった諸国の表を作る.
In[7]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_186.png)
nationalityTallies =
Reverse[SortBy[
Tally[EntityValue["ChicagoMarathon2015",
EntityProperty["ChicagoMarathon2015", "Country"]]], Last]];
完全なWolfram言語入力を表示する
Out[8]//TraditionalForm=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_134.png)
ランナーの全出身国からシカゴまでの測地経路を可視化する.
In[9]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_188.png)
With[{chicago =
Entity["City", {"Chicago", "Illinois", "UnitedStates"}]},
GeoGraphics[{Darker[Green],
GeoPath[{chicago, #} & /@ nationalityTallies[[All, 1]],
"Geodesic"]},
GeoRange -> "World",
GeoProjection -> "Robinson",
GeoCenter -> chicago]]
Out[9]=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_135.png)
アメリカ国籍の参加者の出身地を示す合衆国のヒートマップを作る.
完全なWolfram言語入力を表示する
Out[12]=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_136.png)
区間平均から差異ごとにランナー数を求める.
In[13]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_193.png)
allkm = Table[
Normal[allTimeSplits[[i]][2 ;;, "Time"]], {i,
Length[allTimeSplits]}];
In[13]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_194.png)
allsplitbins = DeleteMissing[Transpose[allkm], 2];
In[13]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_195.png)
meanall = Table[N[Mean[allsplitbins[[i]]]], {i, Length[allsplitbins]}]
Out[13]=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_137.png)
In[13]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_196.png)
marathondistances = (allTimeSplits[[1]])[All, "Split"] // Normal
Out[13]=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_138.png)
In[13]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_197.png)
differencesall = Table[{marathondistances[[i + 1]],
allsplitbins[[i]] - meanall[[i]]},
{i, Length[allsplitbins]}];
In[13]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_198.png)
allHistograms =
Histogram[#2, {60}, PlotLabel -> NumberForm[#1, {3, 1}]] & @@@
differencesall;
各区間についてのヒストグラムを生成する.
In[14]:=
![Click for copyable input](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/In_199.png)
Grid[Partition[allHistograms, UpTo[3]]]
Out[15]=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_139.png)
ランナーが区間を走った時間と平均時間の差の平滑化カーネル分布をプロットする.
完全なWolfram言語入力を表示する
Out[17]=
![](assets.ja/running-the-numbers-on-the-2015-chicago-marathon/O_140.png)