概要
以下の記事にてR実装されていた可視化の処理をPythonで実装してみました。
イグノーベル賞Talent vs Luck論文にPythonとRで反論を試みる
以降、上記記事を単に「参考記事」と記述します。
背景
2022年にイグノーベル賞を受賞したいわゆる「Talent vs Luck論文」の再現を試みようとしていたところ、参考記事を発見しました。コードはほぼそのままで動かすことができたのですが、可視化部分だけ(Rの環境構築が面倒だったので)Pythonで新たに実装しました。せっかくなので、コードを公開します。
可視化の実装
Jupyter notebookにて実行しています。
必要ライブラリは事前にpipなどでインストールしておきます。
ライブラリを読み込みます。
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import pearsonr
参考記事のsimulator.pyにて出力したファイル(data.csv)を読み込みます。
df = pd.read_csv("output/data.csv")
才能、富の分布を確認します。
# 参考:https://qiita.com/trami/items/bd54f22ee4449421f2bc
# figure()でグラフを表示する領域をつくり,figというオブジェクトにする.
fig = plt.figure(figsize=(12,6))
#add_subplot()でグラフを描画する領域を追加する.引数は行,列,場所
ax1 = fig.add_subplot(1, 2, 1)
ax2 = fig.add_subplot(1, 2, 2)
# Check talent distribution
ax1.hist(df["talent"], bins=100)
ax1.set_title("talent")
# Check wealth distribution
# log-lin
binwidth = 50
data = df["wealth"]
ax2.hist(data, bins=np.arange(min(data), max(data) + binwidth, binwidth))
ax2.set_title("wealth")
fig.tight_layout() #レイアウトの設定
plt.show()
パレートの法則(上位20%が80%の富をもつ)を確認します
# Check Pareto's "80-20" rule
print(sum(sorted(df["wealth"], reverse=True)[:int(0.20*len(df))]) / df["wealth"].sum())
print(sum(sorted(df["wealth"])[:int(0.80*len(df))]) / sum(df["wealth"]))
0.7834364529018474
0.2165635470981526
才能と富の関係を可視化します
# 参考:https://qiita.com/trami/items/bd54f22ee4449421f2bc
#figure()でグラフを表示する領域をつくり,figというオブジェクトにする.
fig = plt.figure(figsize=(12,6))
#add_subplot()でグラフを描画する領域を追加する.引数は行,列,場所
ax1 = fig.add_subplot(1, 2, 1)
ax2 = fig.add_subplot(1, 2, 2)
# Check wealth distribution with talent
ax1.scatter(df["wealth"], df["talent"])
ax1.set_xscale("log")
ax1.set_xlabel("wealth")
ax1.set_ylabel("talent")
ax2.scatter(df["talent"], df["wealth"])
ax2.set_xlabel("talent")
ax2.set_ylabel("wealth")
#fig.tight_layout() #レイアウトの設定
plt.show()
才能と富の相関係数を出力します
# 参考 https://qiita.com/dacciinfo/items/85c02c515f852c3c0bea
# Check Pearson's correlation between wealth and talent
correlation, pvalue = pearsonr(df["wealth"],df["talent"])
print("correlation = {}, pvalue = {}".format(correlation, pvalue))
correlation = 0.062222797822971604, pvalue = 0.049171342357307
運(幸運の遭遇回数、不運の遭遇回数)と富の関係を可視化します。
# 参考:https://qiita.com/trami/items/bd54f22ee4449421f2bc
#figure()でグラフを表示する領域をつくり,figというオブジェクトにする.
fig = plt.figure(figsize=(12,6))
#add_subplot()でグラフを描画する領域を追加する.引数は行,列,場所
ax1 = fig.add_subplot(1, 2, 1)
ax2 = fig.add_subplot(1, 2, 2)
# Check wealth distribution with luck
ax1.scatter(df["lucky_cnt"], df["wealth"])
ax1.set_xscale("log")
ax1.set_xlabel("luck")
ax1.set_ylabel("wealth")
ax2.scatter(df["unlucky_cnt"], df["wealth"])
ax2.set_xscale("log")
ax2.set_xlabel("unluck")
ax2.set_ylabel("wealth")
#fig.tight_layout() #レイアウトの設定
plt.show()
運と富の相関係数を出力します。
# 参考 https://qiita.com/dacciinfo/items/85c02c515f852c3c0bea
# Check Pearson's correlation between wealth and talent
correlation, pvalue = pearsonr(df["lucky_cnt"],df["wealth"])
print("lucky: correlation = {}, pvalue = {}".format(correlation, pvalue))
correlation, pvalue = pearsonr(df["unlucky_cnt"],df["wealth"])
print("unluchy: correlation = {}, pvalue = {}".format(correlation, pvalue))
lucky: correlation = 0.35291657504769114, pvalue = 1.0592739633496861e-30
unluchy: correlation = -0.2662094919554471, pvalue = 1.1022326379612243e-17
以上です。
おまけ(論文の感想)
- 現実問題として、成功においては運が大切、というのはそのとおりかなと思う。でも論文がその根拠を十分に与えているかというとシミュレーション、議論が粗い気もした。
- 論文の主張は「『チャンスに巡り合う回数』と『そのチャンスをものにする確率』のうち、前者のほうが富に対する影響が大きい」くらいの表現のほうが受け入れやすい。論文では前者を「運」、後者を「才能」と表現しているが、参考記事でも指摘されていたように、また論文自体も述べているように、チャンスに巡り合う回数を努力や工夫で増やすことは可能なので、それ(努力や工夫による増減が可能なもの)を「運」とラベルづけするのは少しミスリーディングに思える。(とはいえ他の適切な短い言葉がとっさに思いつかないので自分がこの論文の著者だったらやっぱり「運」と言いたくなってしまうかもしれませんが)
- 現実の富がべき分布しているのは「お金が割合でふえる」からであって、富と才能の関係が強かったとしてもべき分布しうると思うので、「富の分布が才能の分布と異なっているのは変では?」という導入は(最初、納得しかけたけど)適切なのかどうか、よくわからなかった。
- モデルが妥当であることの根拠がパレートの法則を満たすことだけだと苦しい気がする。参考記事でも指摘されていたように、パレートの法則を満たすというだけだと条件がゆるすぎて、パラメータを恣意的に設定する余地が残ってしまっているように思う。
- 例えば、今回のモデルでは、才能も運も「金額を増やす」回数の期待値を上げるという意味では本質的に同じ役割をもっている。才能は凡人0.6に対して最大でも5/3倍(才能1のとき)にしかならないのに対して、幸運イベントの発生回数は10倍とかの差が付きうるので、今回の設定では「運」の影響が大きくなるのは自明に思える。「才能が0.1増えるとチャンスをモノにする確率が10倍になる」みたいな条件でパレートの法則を満たすモデルもたぶん作れなくはないわけで、本当に今回のモデルが妥当なの?というのは気になった。
- 不運イベント時の富の減少は、交通事故とかを想定するなら、割合ではなく定数であるべきでは? 人一人治療する金額は、現在の資産に比例するわけではないと思ったので。
参考文献
ソースコードを参考にさせていただいたQiita記事とGitHubレポジトリ
元論文
- Pluchino, A., Biondo, A. E., & Rapisarda, A.(2018). Talent vs. Luck: The Role of Randomness in Success and Failure,Advances in Complex Systems, 21[3,4]. https://doi.org/10.1142/S0219525918500145
ライブラリの使い方