-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.htm
209 lines (195 loc) · 5.67 KB
/
index.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css" />
<link rel="icon" href="favicon.png" />
<script src="src/SharedPromise.js"></script>
<script src="src/WebWorkerEngine.js"></script>
<script src="src/Raffle.js"></script>
<script src="src/NSI.js"></script>
<script src="src/UIUtils.js"></script>
<script src="src/Graph.js"></script>
<script src="src/RaffleSelectUI.js"></script>
<script src="src/ProbabilityUI.js"></script>
<script src="src/InvestmentUI.js"></script>
<title>Raffle Predictor</title>
<script>
window.addEventListener('DOMContentLoaded', () => {
Raffle.set_engine(new SharedWebWorkerEngine({
workers: (navigator.hardwareConcurrency - 1) || 1,
}));
const markers = [
{name: 'Averages'},
{col: '#0033CC', name: 'Mean', value: (r) => r.mean()},
{col: '#0077AA', name: 'Median', value: (r) => r.median()},
{col: '#009900', name: 'Mode', value: (r) => r.mode()},
{name: 'Percentiles'},
{
col: '#CCAA66',
fullName: '25th Percentile',
name: '25th',
value: (r) => r.percentile(25),
},
{
col: '#AA66FF',
fullName: '75th Percentile',
name: '75th',
value: (r) => r.percentile(75),
},
{
col: '#CC6666',
fullName: '95th Percentile',
name: '95th',
value: (r) => r.percentile(95),
},
];
const currencyCode = 'GBP';
const maxMonths = 12 * 20;
const maxTickets = 50000;
const ticketCost = 1;
const raffleSelectUI = new RaffleSelectUI({currencyCode});
const probabilityUI = new ProbabilityUI({
GraphClass: Graph,
currencyCode,
defaultTickets: 10000,
graphLimit: 10000,
markers,
maxMonths: 12 * 30,
maxTickets,
ticketCost,
});
const investmentUI = new InvestmentUI({
GraphClass: Graph,
currencyCode,
markers,
maxMonths: 12 * 10,
maxTickets,
minTickets: 0,
stepTickets: 100,
ticketCost,
});
raffleSelectUI.set_callback((raffle) => {
probabilityUI.set_raffle(raffle);
investmentUI.set_raffle(raffle);
});
raffleSelectUI.add_loader('Load latest prizes from NS&I', () =>
NSI.load().then(({last, next}) => {
if(last) {
raffleSelectUI.add(
'Previous NS&I Raffle',
Raffle.from(last, {pCutoff: 1e-10})
);
}
if(next) {
raffleSelectUI.select(raffleSelectUI.add(
'Predicted Next NS&I Raffle',
Raffle.from(next, {pCutoff: 1e-10})
));
}
})
);
raffleSelectUI.add(
'NS&I Premium Bonds Snapshot used by MSE',
Raffle.from(new NSI([
{value: 1000000, count: 2},
{value: 100000, count: 4},
{value: 50000, count: 10},
{value: 25000, count: 17},
{value: 10000, count: 43},
{value: 5000, count: 87},
{value: 1000, count: 1677},
{value: 500, count: 5031},
{value: 100, count: 22984},
{value: 50, count: 22984},
{value: 25, count: 2879959},
{value: 0, count: 71850560383},
]), {pCutoff: 1e-10})
);
raffleSelectUI.add(
'NS&I Premium Bonds Snapshot (March 2018)',
Raffle.from(new NSI([
{value: 1000000, count: 2},
{value: 100000, count: 5},
{value: 50000, count: 8},
{value: 25000, count: 19},
{value: 10000, count: 46},
{value: 5000, count: 92},
{value: 1000, count: 1717},
{value: 500, count: 5151},
{value: 100, count: 23554},
{value: 50, count: 23554},
{value: 25, count: 2950583},
], {audienceMultiplier: 24500}), {pCutoff: 1e-10})
);
raffleSelectUI.add(
'NS&I Premium Bonds Snapshot (September 2020)',
Raffle.from(new NSI([
{value: 1000000, count: 2},
{value: 100000, count: 7},
{value: 50000, count: 14},
{value: 25000, count: 28},
{value: 10000, count: 71},
{value: 5000, count: 140},
{value: 1000, count: 2204},
{value: 500, count: 6612},
{value: 100, count: 30244},
{value: 50, count: 30244},
{value: 25, count: 3786474},
], {audienceMultiplier: 24500}), {pCutoff: 1e-10})
);
raffleSelectUI.add(
'NS&I Premium Bonds Snapshot (November 2020)',
Raffle.from(new NSI([
{value: 1000000, count: 2},
{value: 100000, count: 7},
{value: 50000, count: 15},
{value: 25000, count: 30},
{value: 10000, count: 75},
{value: 5000, count: 147},
{value: 1000, count: 2274},
{value: 500, count: 6822},
{value: 100, count: 31198},
{value: 50, count: 31198},
{value: 25, count: 3906518},
], {audienceMultiplier: 24500}), {pCutoff: 1e-10})
);
raffleSelectUI.select(raffleSelectUI.add(
'NS&I Premium Bonds Snapshot (December 2020)',
Raffle.from(new NSI([
{value: 1000000, count: 2},
{value: 100000, count: 4},
{value: 50000, count: 9},
{value: 25000, count: 16},
{value: 10000, count: 43},
{value: 5000, count: 83},
{value: 1000, count: 1639},
{value: 500, count: 4917},
{value: 100, count: 26637},
{value: 50, count: 26637},
{value: 25, count: 2790269},
], {audienceMultiplier: 34500}), {pCutoff: 1e-10})
));
document.body.appendChild(raffleSelectUI.dom());
document.body.appendChild(investmentUI.dom());
document.body.appendChild(probabilityUI.dom());
});
</script>
</head>
<body>
<section class="info">
<h1>Raffle Predictor</h1>
<p>
This tool calculates odds of winning various prizes in a monetary raffle.
It is designed specifically to calculate
<a href="https://www.nsandi.com/premium-bonds" target="_blank">NS&I Premium
Bonds</a>, but will work with any similar scheme.
</p>
<p>
For full details,
<a href="https://github.com/davidje13/Raffle" target="_blank">see the project
on GitHub</a>.
</p>
</section>
</body>
</html>