Skip to content

Instantly share code, notes, and snippets.

@0xeuclid
Created November 26, 2012 07:23
Show Gist options
  • Select an option

  • Save 0xeuclid/4147016 to your computer and use it in GitHub Desktop.

Select an option

Save 0xeuclid/4147016 to your computer and use it in GitHub Desktop.
compute expected value of Taiwan invoice
=begin
#--- OUTPUT :
0.1
0.02
0.005999999999999999
0.012
0.030000000000000002
0.12000000000000001
0.3
1.0
"Expected Value : 1.588"
=end
# Value of money
# m = million, t = thousand, h = hundred
v10m = 10000000
v2m = 2000000
v200t = 200000
v40t = 40000
v10t = 10000
v4t = 4000
v1t = 1000
v2h = 200
# Probability
p10m = 1.0/100000000
p2m = 1.0/100000000
p200t = 3.0/100000000
p40t = 3.0/10000000
p10t = 3.0/1000000
p4t = 3.0/100000
p1t = 3.0/10000
p2h = 5.0/1000
# EV : expected values
p e10m = v10m * p10m
p e2m = v2m * p2m
p e200t = v200t * p200t
p e40t = v40t * p40t
p e10t = v10t * p10t
p e4t = v4t * p4t
p e1t = v1t * p1t
p e2h = v2h * p2h
# Sum of EV
sumEV = e10m+e2m+e200t+e40t+e10t+e4t+e1t+e2h
p "Expected Value : #{sumEV}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment