-
Notifications
You must be signed in to change notification settings - Fork 3
/
beta_unbounded.html
72 lines (67 loc) · 2.13 KB
/
beta_unbounded.html
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://d3js.org/d3.v6.js"></script>
<script src="math-js-wasm/beta_unbounded.js"></script>
<script src="stan-distribution-zoo.js?v=1"></script>
<script>
var x;
var y;
var svg;
var xAxis;
var yAxis;
var data = [];
var params = {
yupp: 300,
mu: 0.5,
phi: 120
};
var continuous = true;
function update_data() {
data = []
for (let y = 0.1; y < params.yupp; y = y + 0.01) {
let res = Module.beta_unbounded_lpdf(y, params.yupp, params.mu, params.phi)
if ($("#exp-check")[0].checked) {
res = Math.exp(res)
}
data.push({ ser1: y, ser2: res})
}
}
var Module = {
onRuntimeInitialized: function () {
setup_page(
{
function_name: "beta_unbounded_lpdf(y | yupp, mu, phi)",
sliders: [
{
name: "yupp", text: "yupp",
value: params.yupp, min: 1, max: 500, step: 1
},
{
name: "mu", text: "mu",
value: params.mu, min: 0.01, max: 1, step: 0.01
},
{
name: "phi", text: "phi",
value: params.phi, min: 0.01, max: 200, step: 0.1
}
],
exponentiate: true,
continuous: true,
x_axis_text: "y",
additional_text: '<div style=\"width: 50%;margin: auto;\"><h3>Stan code:</h3><pre>'+' real beta_unbounded_lpdf(real y, real yupp, real mu, real phi) {\n'+' real denominator = (phi - 1)*log(yupp);\n'+
' real logGamma = lgamma(phi)-(lgamma(mu*phi) + lgamma((1-mu)*phi));\n'+' real numerator = (mu*phi-1)*log(y) + ((1-mu)*phi-1)*log(yupp - y);\n'+
' ' + ' return numerator - denominator + logGamma;\n' + ' }\n'+ ' </pre></div>'
}
)
}
}
</script>
</head>
<body>
<div id="figure"></div>
</body>
</html>