-
Notifications
You must be signed in to change notification settings - Fork 5
/
Earthquake Magician_JMKII.htm
130 lines (124 loc) · 4.45 KB
/
Earthquake Magician_JMKII.htm
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html class=""><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="application/shiny-singletons"></script>
<script type="application/html-dependencies">json2[2014.02.04];jquery[1.12.4];shiny[1.2.0];selectize[0.11.2];bootstrap[3.3.7]</script>
<script src="Earthquake%20Magician-Dateien/json2-min.js"></script>
<script src="Earthquake%20Magician-Dateien/jquery.js"></script>
<link href="Earthquake%20Magician-Dateien/shiny.css" rel="stylesheet">
<script src="Earthquake%20Magician-Dateien/shiny.js"></script>
<link href="Earthquake%20Magician-Dateien/selectize.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="shared/selectize/js/es5-shim.min.js"></script>
<![endif]-->
<script src="Earthquake%20Magician-Dateien/selectize.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="Earthquake%20Magician-Dateien/bootstrap.css" rel="stylesheet">
<script src="Earthquake%20Magician-Dateien/bootstrap.js"></script>
<script src="Earthquake%20Magician-Dateien/html5shiv.js"></script>
<script src="Earthquake%20Magician-Dateien/respond.js"></script>
</head>
<body>
<div class="container-fluid">
Magician Michelle says that she can predict large megathrust
earthquakes... well, at least 95% of the time. Assume that these
earthquakes occur with a probability of 10^-5.How likely will Michelle
cause a false alarm with her next prediction?
<hr>
<div>
Given our scenario we have following probabilities:
</div>
<div>
<li>
<code># Probabilities</code>
</li>
</div>
<div>
<li>
<code> P_m <- 0.95 # Prob. Michelle is correct</code>
</li>
</div>
<div>
<li>
<code> P_mc <- 1-P_m # Prob. Michelle is wrong</code>
</li>
</div>
<div>
<li>
<code> P_e <- (10^-5) # Prob. of Earthquake occurance</code>
</li>
</div>
<div>
<li>
<code> P_ec <- 1-P_e # Prob. of NO Earthquake occurance</code>
</li>
</div>
<hr>
<div>
IN our scenario we have no earthquake ('Ec'), even though Michelle predicted one ('Mc').
</div>
<div>
<h2>P(Mc | Ec)</h2>
</div>
<div>
Resolving Bayes law we get:
</div>
<div>
<h3>P(Mc | Ec) = (P(Ec | Mc) * P(Mc)) / ((P(Ec | Mc) * P(Mc)) + ((P(Ec | M) * P(M))</h3>
</div>
<div>
M - Michelle Right, Mc - Michelle Wrong, E - Earthquake, Ec - NO Earthquake
</div>
<div>
<li>
<code># Calculating products of Posteriors</code>
</li>
</div>
<div>
<li>
<code>P_ec_mc <- P_ec * P_mc</code>
</li>
</div>
<div>
<li>
<code>P_ec_m <- P_ec * P_m</code>
</li>
</div>
<hr>
<div>
<li>
<code>#Calculating wanted probability</code>
</li>
</div>
<div>
<li>
<code>P_mc_ec <- (P_ec_mc) / ((P_ec_mc) + (P_ec_m))</code>
</li>
</div>
<div>
<li>
<code>returnValue(P_mc_ec)</code>
</li>
</div>
<hr>
<div>
Would the probability of Michelle's prediction change with different Earthquake types? (i.e. different probabilities)
</div>
<div class="col-sm-4">
<form class="well">
<span class="help-block">Select Earthquake Probability</span>
<div class="form-group shiny-input-container">
<label class="control-label" for="num-selectized">Earthquake Probabilitty</label>
<div>
<select id="num" tabindex="-1" style="display: none;" class="selectized shiny-bound-input"><option value="10^-5" selected="selected">10^-5</option></select><div class="selectize-control single"><div class="selectize-input items full has-options has-items"><div class="item" data-value="10^-5">10^-5</div><input type="text" autocomplete="off" tabindex="" id="num-selectized" style="width: 4px;" class="shiny-bound-input"></div><div class="selectize-dropdown single" style="display: none;"><div class="selectize-dropdown-content"></div></div></div>
<script type="application/json" data-for="num" data-nonempty="">{}</script>
</div>
</div>
<div>
Probability: 0.05
</div>
<div id="selected_num" class="shiny-text-output shiny-bound-output">You selected 10^-5</div>
</form>
</div>
</div>
</body></html>