-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhello_expected_utility.py
49 lines (38 loc) · 1.28 KB
/
hello_expected_utility.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 14 11:29:55 2018
@author: soenk
"""
# Function to calculate expected utility of an action(in this case, restaurant)
def expected_utility(p, v):
exp_u = 0
for i in range(len(p)):
exp_u += p[i] * v[i]
return exp_u
# Probability list of the expensive restaurant, action 1
p_thelibrije = [
0.05, # Probability of a low bill
0.9 # Probability of high quality food
]
p_febo = [
0.86,
0.2
]
# Value list of the agents
v_wa_van_buren = [
0.01, # Importance of low bill
0.95 # Importance of high quality food
]
v_tokkie = [
0.9,
0.1
]
# Calculating expected utility for both agents
eu_wa_lib = expected_utility(p_thelibrije,v_wa_van_buren)
eu_wa_feb = expected_utility(p_febo,v_wa_van_buren)
eu_tok_lib = expected_utility(p_thelibrije,v_tokkie)
eu_tok_feb = expected_utility(p_febo,v_tokkie)
print("WA has an Expected Utility for de Librije of: " + str(eu_wa_lib) +
" and an Expected Utility for Febo of: " + str(eu_wa_feb) + ".")
print("Tokkie has an Expected Utility for de Librije of: " + str(eu_tok_lib) +
" and an Expected Utility for Febo of: " + str(eu_tok_feb) + ".")