-
Notifications
You must be signed in to change notification settings - Fork 3
/
poisson.html
64 lines (60 loc) · 1.61 KB
/
poisson.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
<!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/poisson.js"></script>
<script src="stan-distribution-zoo.js"></script>
<script>
var x;
var y;
var svg;
var xAxis;
var yAxis;
var data = [];
var params = {
n_range: 40,
lambda: 10
};
var continuous = false;
function update_data() {
data = []
for (let n = 0; n < params.n_range; n = n + 1) {
let res = Module.poisson_lpmf(n, params.lambda)
if ($("#exp-check")[0].checked) {
res = Math.exp(res)
}
data.push({ ser1: n, ser2: res})
}
}
var Module = {
onRuntimeInitialized: function() {
$(document).ready(function(){
setup_page(
{
function_name: "poisson_lpmf (n | lambda)",
sliders: [
{
name: "n_range", text: "Range of n",
value: params.n_range, min: 1, max: 100, step: 1
},
{
name: "lambda", text: "lambda",
value: params.lambda, min: 0, max: 50, step: 0.1
}
],
exponentiate: true,
x_axis_text: "n"
}
)
})
}
}
</script>
</head>
<body>
<div id="figure"></div>
</body>
</html>