統計的決定

問題解決の数理 第10章 統計的決定

Rで期待効用計算(ptパッケージを使用)

外出の問題

必要なパッケージの読み込み

1
2
3
4
5
library(methods)
library("pt")
library(knitr)
#library(grid)
#library(roxygen2)
傘を持つ(1)、傘を持たない(2)
1
2
3
4
5
6
7
8
choice_ids <- c(1, 1, 1, 1)
gamble_ids <- c(1, 1, 2, 2)
probability_strings <- c("0.5", "0.5", "0.5", "0.5")
outcome_ids <- c(1, 2, 1, 2)
objective_consequences <- c(40,20,0,100)
my_choices <- Choices(choice_ids=choice_ids,gamble_ids=gamble_ids,outcome_ids=outcome_ids,objective_consequences=objective_consequences,
probability_strings=probability_strings)
kable(compareEV(my_choices, digits=4))
cid gid ev
1 1 30
1 2 50
(期待効用)傘を持つ(1)・・30、傘を持たない(2)・・50
簡単なグラフも描けます
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
drawChoices(my_choices,
decision_square_x=0.2, decision_square_edge_length=0.05,
circle_radius=0.025, y_split_gap=0.1, x_split_offset=0.03,
probability_text_digits=4, y_probability_text_offset=0.015,
y_value_text_offset=0.005, x_value_text_offset=0.025,
probability_text_font_colour="red", probability_text_font_size=11,
objective_consequence_text_font_colour="blue",
objective_consequence_text_font_size=11,
#ラベルが不要な時はここから
label=c("持つ","持たない","降る", "降らない","降る","降らない"),
label_font_colour=c("orange","magenta","green","blue","green","blue"),
label_font_size=c(10,10,10,10,10,10),
label_positions=list(c(0.26,0.62),c(0.26,0.42),c(0.372,0.63),c(0.372,0.53),c(0.372,0.43),c(0.372,0.33))
#ここまで、コメントアウトする。すぐ下のカッコは必要です。
)

資源採掘の問題

D2(標準採掘が失敗した場合の決断)

採掘断念(1)、強化採掘を行う(2)
1
2
3
4
5
6
7
8
choice_ids <- c(1,1,1)
gamble_ids <- c(1,2,2)
probability_strings <- c("1", "0.9", "0.1")
outcome_ids <- c(1,1,2)
objective_consequences <- c(-200, 500,-700)
my_choices <- Choices(choice_ids=choice_ids,gamble_ids=gamble_ids,outcome_ids=outcome_ids,objective_consequences=objective_consequences,
probability_strings=probability_strings)
kable(compareEV(my_choices, digits=4))
cid gid ev
1 1 -200
1 2 380
(期待効用)採掘断念(1)・・ー200 、強化採掘を行う(2)・・380
1
2
3
4
5
6
7
8
9
10
11
12
13
drawChoices(my_choices,
decision_square_x=0.2, decision_square_edge_length=0.05,
circle_radius=0.025, y_split_gap=0.1, x_split_offset=0.03,
probability_text_digits=4, y_probability_text_offset=0.015,
y_value_text_offset=0.005, x_value_text_offset=0.025,
probability_text_font_colour="red", probability_text_font_size=11,
objective_consequence_text_font_colour="blue",
objective_consequence_text_font_size=11,
label=c("採掘断念","強化採掘","成功", "失敗","(-400)"),
label_font_colour=c("orange","magenta","green","blue","red"),
label_font_size=c(10,10,10,10,11),
label_positions=list(c(0.25,0.62),c(0.25,0.42),c(0.372,0.48),c(0.372,0.38),c(0.15,0.54))
)

D1(最初に行うのは標準採掘か強化採掘かの決断)

標準採掘(1)、強化採掘(2)
1
2
3
4
5
6
7
8
choice_ids <- c(1,1,1,1)
gamble_ids <- c(1, 1, 2, 2)
probability_strings <- c("0.7", "0.3", "0.9", "0.1")
outcome_ids <- c(1, 2, 1, 2)
objective_consequences <- c(600,-20,500,-700)
my_choices <- Choices(choice_ids=choice_ids,gamble_ids=gamble_ids,outcome_ids=outcome_ids,objective_consequences=objective_consequences,
probability_strings=probability_strings)
kable(compareEV(my_choices, digits=4))
cid gid ev
1 1 414
1 2 380
(期待効用)標準採掘(1)・・414、強化採掘(2)・・380
1
2
3
4
5
6
7
8
9
10
11
12
13
drawChoices(my_choices,
decision_square_x=0.2, decision_square_edge_length=0.05,
circle_radius=0.025, y_split_gap=0.1, x_split_offset=0.03,
probability_text_digits=4, y_probability_text_offset=0.015,
y_value_text_offset=0.005, x_value_text_offset=0.025,
probability_text_font_colour="red", probability_text_font_size=11,
objective_consequence_text_font_colour="blue",
objective_consequence_text_font_size=11,
label=c("標準採掘","強化採掘","成功", "失敗","成功","失敗"),
label_font_colour=c("orange","magenta","green","blue","green","blue"),
label_font_size=c(10,10,10,10,10,10),
label_positions=list(c(0.26,0.62),c(0.26,0.42),c(0.372,0.63),c(0.372,0.53),c(0.372,0.43),c(0.372,0.33))
)

「最初に標準採掘を行い、もしも失敗したら強化採掘を行う。」が期待効用最大。