-
Notifications
You must be signed in to change notification settings - Fork 0
/
score.html
764 lines (707 loc) · 31.9 KB
/
score.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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="success.css">
<meta property="og:url" content="https://www.aforeseeablefuture.com" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Foreseeable Future" />
<meta property="og:description" content="Predicting the future isn't a superpower, it's the primary skill we use when we decide what to build. Like any skill, you can get better with practice." />
<meta property="og:image" content="https://www.aforeseeablefuture.com/logo.jpg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="fb:app_id" content="248388065568194" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@hernandez_danny" />
<meta name="twitter:title" content="Foreseeable Future" />
<meta name="twitter:description" content="Predicting the future isn't a superpower, it's the primary skill we use when we decide what to build. Like any skill, you can get better with practice." />
<meta name="twitter:image" content="https://www.aforeseeablefuture.com/icon.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#ffffff">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://use.fontawesome.com/38cda031e5.js"></script>
<!-- HORRIBLE HACK! dont inline this js -->
<script>
var retina = window.devicePixelRatio,
// Math shorthands
PI = Math.PI,
sqrt = Math.sqrt,
round = Math.round,
random = Math.random,
cos = Math.cos,
sin = Math.sin,
// Local WindowAnimationTiming interface
rAF = window.requestAnimationFrame,
cAF = window.cancelAnimationFrame || window.cancelRequestAnimationFrame,
_now = Date.now || function() {
return new Date().getTime();
};
// Local WindowAnimationTiming interface polyfill
(function(w) {
/**
* Fallback implementation.
*/
var prev = _now();
function fallback(fn) {
var curr = _now();
var ms = Math.max(0, 16 - (curr - prev));
var req = setTimeout(fn, ms);
prev = curr;
return req;
}
/**
* Cancel.
*/
var cancel = w.cancelAnimationFrame || w.webkitCancelAnimationFrame || w.clearTimeout;
rAF = w.requestAnimationFrame || w.webkitRequestAnimationFrame || fallback;
cAF = function(id) {
cancel.call(w, id);
};
}(window));
document.addEventListener("DOMContentLoaded", function() {
var speed = 50,
duration = (1.0 / speed),
confettiRibbonCount = 11,
ribbonPaperCount = 1,
ribbonPaperDist = 8.0,
ribbonPaperThick = 8.0,
confettiPaperCount = 95,
DEG_TO_RAD = PI / 180,
RAD_TO_DEG = 180 / PI,
colors = [
["#FFF", "#34E5FA"],
["#FFF", "#F865AA"],
["#FFF", "#653056"],
["#FFF", "#B294C8"],
];
function Vector2(_x, _y) {
this.x = _x, this.y = _y;
this.Length = function() {
return sqrt(this.SqrLength());
}
this.SqrLength = function() {
return this.x * this.x + this.y * this.y;
}
this.Add = function(_vec) {
this.x += _vec.x;
this.y += _vec.y;
}
this.Sub = function(_vec) {
this.x -= _vec.x;
this.y -= _vec.y;
}
this.Div = function(_f) {
this.x /= _f;
this.y /= _f;
}
this.Mul = function(_f) {
this.x *= _f;
this.y *= _f;
}
this.Normalize = function() {
var sqrLen = this.SqrLength();
if (sqrLen != 0) {
var factor = 1.0 / sqrt(sqrLen);
this.x *= factor;
this.y *= factor;
}
}
this.Normalized = function() {
var sqrLen = this.SqrLength();
if (sqrLen != 0) {
var factor = 1.0 / sqrt(sqrLen);
return new Vector2(this.x * factor, this.y * factor);
}
return new Vector2(0, 0);
}
}
Vector2.Lerp = function(_vec0, _vec1, _t) {
return new Vector2((_vec1.x - _vec0.x) * _t + _vec0.x, (_vec1.y - _vec0.y) * _t + _vec0.y);
}
Vector2.Distance = function(_vec0, _vec1) {
return sqrt(Vector2.SqrDistance(_vec0, _vec1));
}
Vector2.SqrDistance = function(_vec0, _vec1) {
var x = _vec0.x - _vec1.x;
var y = _vec0.y - _vec1.y;
return (x * x + y * y + z * z);
}
Vector2.Scale = function(_vec0, _vec1) {
return new Vector2(_vec0.x * _vec1.x, _vec0.y * _vec1.y);
}
Vector2.Min = function(_vec0, _vec1) {
return new Vector2(Math.min(_vec0.x, _vec1.x), Math.min(_vec0.y, _vec1.y));
}
Vector2.Max = function(_vec0, _vec1) {
return new Vector2(Math.max(_vec0.x, _vec1.x), Math.max(_vec0.y, _vec1.y));
}
Vector2.ClampMagnitude = function(_vec0, _len) {
var vecNorm = _vec0.Normalized;
return new Vector2(vecNorm.x * _len, vecNorm.y * _len);
}
Vector2.Sub = function(_vec0, _vec1) {
return new Vector2(_vec0.x - _vec1.x, _vec0.y - _vec1.y, _vec0.z - _vec1.z);
}
function EulerMass(_x, _y, _mass, _drag) {
this.position = new Vector2(_x, _y);
this.mass = _mass;
this.drag = _drag;
this.force = new Vector2(0, 0);
this.velocity = new Vector2(0, 0);
this.AddForce = function(_f) {
this.force.Add(_f);
}
this.Integrate = function(_dt) {
var acc = this.CurrentForce(this.position);
acc.Div(this.mass);
var posDelta = new Vector2(this.velocity.x, this.velocity.y);
posDelta.Mul(_dt);
this.position.Add(posDelta);
acc.Mul(_dt);
this.velocity.Add(acc);
this.force = new Vector2(0, 0);
}
this.CurrentForce = function(_pos, _vel) {
var totalForce = new Vector2(this.force.x, this.force.y);
var speed = this.velocity.Length();
var dragVel = new Vector2(this.velocity.x, this.velocity.y);
dragVel.Mul(this.drag * this.mass * speed);
totalForce.Sub(dragVel);
return totalForce;
}
}
function ConfettiPaper(_x, _y) {
this.pos = new Vector2(_x, _y);
this.rotationSpeed = (random() * 600 + 800);
this.angle = DEG_TO_RAD * random() * 360;
this.rotation = DEG_TO_RAD * random() * 360;
this.cosA = 1.0;
this.size = 5.0;
this.oscillationSpeed = (random() * 1.5 + 0.5);
this.xSpeed = 40.0;
this.ySpeed = (random() * 60 + 50.0);
this.corners = new Array();
this.time = random();
var ci = round(random() * (colors.length - 1));
this.frontColor = colors[ci][0];
this.backColor = colors[ci][1];
for (var i = 0; i < 4; i++) {
var dx = cos(this.angle + DEG_TO_RAD * (i * 90 + 45));
var dy = sin(this.angle + DEG_TO_RAD * (i * 90 + 45));
this.corners[i] = new Vector2(dx, dy);
}
this.Update = function(_dt) {
this.time += _dt;
this.rotation += this.rotationSpeed * _dt;
this.cosA = cos(DEG_TO_RAD * this.rotation);
this.pos.x += cos(this.time * this.oscillationSpeed) * this.xSpeed * _dt
this.pos.y += this.ySpeed * _dt;
if (this.pos.y > ConfettiPaper.bounds.y) {
this.pos.x = random() * ConfettiPaper.bounds.x;
this.pos.y = 0;
}
}
this.Draw = function(_g) {
if (this.cosA > 0) {
_g.fillStyle = this.frontColor;
} else {
_g.fillStyle = this.backColor;
}
_g.beginPath();
_g.moveTo((this.pos.x + this.corners[0].x * this.size) * retina, (this.pos.y + this.corners[0].y * this.size * this.cosA) * retina);
for (var i = 1; i < 4; i++) {
_g.lineTo((this.pos.x + this.corners[i].x * this.size) * retina, (this.pos.y + this.corners[i].y * this.size * this.cosA) * retina);
}
_g.closePath();
_g.fill();
}
}
ConfettiPaper.bounds = new Vector2(0, 0);
function ConfettiRibbon(_x, _y, _count, _dist, _thickness, _angle, _mass, _drag) {
this.particleDist = _dist;
this.particleCount = _count;
this.particleMass = _mass;
this.particleDrag = _drag;
this.particles = new Array();
var ci = round(random() * (colors.length - 1));
this.frontColor = colors[ci][0];
this.backColor = colors[ci][1];
this.xOff = (cos(DEG_TO_RAD * _angle) * _thickness);
this.yOff = (sin(DEG_TO_RAD * _angle) * _thickness);
this.position = new Vector2(_x, _y);
this.prevPosition = new Vector2(_x, _y);
this.velocityInherit = (random() * 2 + 4);
this.time = random() * 100;
this.oscillationSpeed = (random() * 2 + 2);
this.oscillationDistance = (random() * 40 + 40);
this.ySpeed = (random() * 40 + 80);
for (var i = 0; i < this.particleCount; i++) {
this.particles[i] = new EulerMass(_x, _y - i * this.particleDist, this.particleMass, this.particleDrag);
}
this.Update = function(_dt) {
var i = 0;
this.time += _dt * this.oscillationSpeed;
this.position.y += this.ySpeed * _dt;
this.position.x += cos(this.time) * this.oscillationDistance * _dt;
this.particles[0].position = this.position;
var dX = this.prevPosition.x - this.position.x;
var dY = this.prevPosition.y - this.position.y;
var delta = sqrt(dX * dX + dY * dY);
this.prevPosition = new Vector2(this.position.x, this.position.y);
for (i = 1; i < this.particleCount; i++) {
var dirP = Vector2.Sub(this.particles[i - 1].position, this.particles[i].position);
dirP.Normalize();
dirP.Mul((delta / _dt) * this.velocityInherit);
this.particles[i].AddForce(dirP);
}
for (i = 1; i < this.particleCount; i++) {
this.particles[i].Integrate(_dt);
}
for (i = 1; i < this.particleCount; i++) {
var rp2 = new Vector2(this.particles[i].position.x, this.particles[i].position.y);
rp2.Sub(this.particles[i - 1].position);
rp2.Normalize();
rp2.Mul(this.particleDist);
rp2.Add(this.particles[i - 1].position);
this.particles[i].position = rp2;
}
if (this.position.y > ConfettiRibbon.bounds.y + this.particleDist * this.particleCount) {
this.Reset();
}
}
this.Reset = function() {
this.position.y = -random() * ConfettiRibbon.bounds.y;
this.position.x = random() * ConfettiRibbon.bounds.x;
this.prevPosition = new Vector2(this.position.x, this.position.y);
this.velocityInherit = random() * 2 + 4;
this.time = random() * 100;
this.oscillationSpeed = random() * 2.0 + 1.5;
this.oscillationDistance = (random() * 40 + 40);
this.ySpeed = random() * 40 + 80;
var ci = round(random() * (colors.length - 1));
this.frontColor = colors[ci][0];
this.backColor = colors[ci][1];
this.particles = new Array();
for (var i = 0; i < this.particleCount; i++) {
this.particles[i] = new EulerMass(this.position.x, this.position.y - i * this.particleDist, this.particleMass, this.particleDrag);
}
}
this.Draw = function(_g) {
for (var i = 0; i < this.particleCount - 1; i++) {
var p0 = new Vector2(this.particles[i].position.x + this.xOff, this.particles[i].position.y + this.yOff);
var p1 = new Vector2(this.particles[i + 1].position.x + this.xOff, this.particles[i + 1].position.y + this.yOff);
if (this.Side(this.particles[i].position.x, this.particles[i].position.y, this.particles[i + 1].position.x, this.particles[i + 1].position.y, p1.x, p1.y) < 0) {
_g.fillStyle = this.frontColor;
_g.strokeStyle = this.frontColor;
} else {
_g.fillStyle = this.backColor;
_g.strokeStyle = this.backColor;
}
if (i == 0) {
_g.beginPath();
_g.moveTo(this.particles[i].position.x * retina, this.particles[i].position.y * retina);
_g.lineTo(this.particles[i + 1].position.x * retina, this.particles[i + 1].position.y * retina);
_g.lineTo(((this.particles[i + 1].position.x + p1.x) * 0.5) * retina, ((this.particles[i + 1].position.y + p1.y) * 0.5) * retina);
_g.closePath();
_g.stroke();
_g.fill();
_g.beginPath();
_g.moveTo(p1.x * retina, p1.y * retina);
_g.lineTo(p0.x * retina, p0.y * retina);
_g.lineTo(((this.particles[i + 1].position.x + p1.x) * 0.5) * retina, ((this.particles[i + 1].position.y + p1.y) * 0.5) * retina);
_g.closePath();
_g.stroke();
_g.fill();
} else if (i == this.particleCount - 2) {
_g.beginPath();
_g.moveTo(this.particles[i].position.x * retina, this.particles[i].position.y * retina);
_g.lineTo(this.particles[i + 1].position.x * retina, this.particles[i + 1].position.y * retina);
_g.lineTo(((this.particles[i].position.x + p0.x) * 0.5) * retina, ((this.particles[i].position.y + p0.y) * 0.5) * retina);
_g.closePath();
_g.stroke();
_g.fill();
_g.beginPath();
_g.moveTo(p1.x * retina, p1.y * retina);
_g.lineTo(p0.x * retina, p0.y * retina);
_g.lineTo(((this.particles[i].position.x + p0.x) * 0.5) * retina, ((this.particles[i].position.y + p0.y) * 0.5) * retina);
_g.closePath();
_g.stroke();
_g.fill();
} else {
_g.beginPath();
_g.moveTo(this.particles[i].position.x * retina, this.particles[i].position.y * retina);
_g.lineTo(this.particles[i + 1].position.x * retina, this.particles[i + 1].position.y * retina);
_g.lineTo(p1.x * retina, p1.y * retina);
_g.lineTo(p0.x * retina, p0.y * retina);
_g.closePath();
_g.stroke();
_g.fill();
}
}
}
this.Side = function(x1, y1, x2, y2, x3, y3) {
return ((x1 - x2) * (y3 - y2) - (y1 - y2) * (x3 - x2));
}
}
ConfettiRibbon.bounds = new Vector2(0, 0);
confetti = {};
confetti.Context = function(id) {
var i = 0;
var canvas = document.getElementById(id);
var canvasParent = canvas.parentNode;
var canvasWidth = canvasParent.offsetWidth;
var canvasHeight = canvasParent.offsetHeight;
canvas.width = canvasWidth * retina;
canvas.height = canvasHeight * retina;
var context = canvas.getContext('2d');
var interval = null;
var confettiRibbons = new Array();
ConfettiRibbon.bounds = new Vector2(canvasWidth, canvasHeight);
for (i = 0; i < confettiRibbonCount; i++) {
confettiRibbons[i] = new ConfettiRibbon(random() * canvasWidth, -random() * canvasHeight * 2, ribbonPaperCount, ribbonPaperDist, ribbonPaperThick, 45, 1, 0.05);
}
var confettiPapers = new Array();
ConfettiPaper.bounds = new Vector2(canvasWidth, canvasHeight);
for (i = 0; i < confettiPaperCount; i++) {
confettiPapers[i] = new ConfettiPaper(random() * canvasWidth, random() * canvasHeight);
}
this.resize = function() {
canvasWidth = canvasParent.offsetWidth;
canvasHeight = canvasParent.offsetHeight;
canvas.width = canvasWidth * retina;
canvas.height = canvasHeight * retina;
ConfettiPaper.bounds = new Vector2(canvasWidth, canvasHeight);
ConfettiRibbon.bounds = new Vector2(canvasWidth, canvasHeight);
}
this.start = function() {
this.stop()
var context = this;
this.update();
}
this.stop = function() {
cAF(this.interval);
}
this.update = function() {
var i = 0;
context.clearRect(0, 0, canvas.width, canvas.height);
for (i = 0; i < confettiPaperCount; i++) {
confettiPapers[i].Update(duration);
confettiPapers[i].Draw(context);
}
for (i = 0; i < confettiRibbonCount; i++) {
confettiRibbons[i].Update(duration);
confettiRibbons[i].Draw(context);
}
this.interval = rAF(function() {
confetti.update();
});
}
}
var confetti = new confetti.Context('confetti');
confetti.start();
window.addEventListener('resize', function(event) {
confetti.resize();
});
});
</script>
<script>
// TODO: move out inline js
$(document).ready(function(){
$('.js-share-fb').click(function() {
FB.ui({
method: 'share',
display: 'popup',
href: 'http://aforeseeablefuture.com'
}, function(response){});
});
$('.js-share-twitter').click(function() {
var url = "https://twitter.com/share?text=I%20just%20practiced%20predicting%20the%20future...%20It%20was%20great%2C%20I%20highly%20recommend%20it.&url=http://aforeseeablefuture.com";
window.open(url, "", "width=500,height=400,resizable=true").focus();
});
});
</script>
<style>
.share-buttons > a {
text-decoration: none;
}
</style>
</head>
<body>
<script>
window.fbAsyncInit = function() {
FB.init({
//TODO make an app on facebook, and add it
appId : '248388065568194',
xfbml : true,
version : 'v2.8'
});
FB.AppEvents.logPageView();
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<script>
// you got x of y right (target is 80%)
// if you had made your intervals x amount wider, you would have been calibrated
// keep that in mindwhen you make forecasts/predictions
// in order to hit ~80% you needed a range size of x multiples
var urlParams = new URLSearchParams(window.location.search);
answerKey = {
netflix_pct: 54,
fb_dau: 1200000000,
ad_spend: 76,
why_voice: 61,
aws_growth: 55,
iphone_sales: 69,
search_mkt: 80.5,
slack_prod: 32,
airbnb_hilton: 1.28,
bitcoin_mktcap: 16700000000,
}
//http://www.aforeseeablefuture.com/?netflix_pct=10-50&fb_dau=300M%20-%201300M&ad_spend=50%20to%2070&why_voice=60&aws_growth=35-70&iphone_sales=50%%20to%2080%&search_mkt=60%20to%2080%&slack_prod=15-40&airbnb_hilton=1.2%20to%201.6&bitcoin_mktcap=10B%20-%2014B
function parseAnswer(answer) {
answer = answer.toLowerCase().trim()
answer = answer.replace(/thousand/g, "k").replace(/k/g, " k")
answer = answer.replace(/million/g, "m").replace(/m/g, " m")
answer = answer.replace(/billion/g, "b").replace(/b/g, " b")
answer = answer.replace(/to/, " ").replace(/-/, " ").replace(/[^0-9 .kmb]/g,'').trim().split(/(?:,-| )+/)
if (answer.length == 1) {
return false
}
if (answer.length == 2) {
return [parseFloat(answer[0]), parseFloat(answer[1])]
}
parsed = []
j = 0
// console.log(parsed)
multiple = [0, 0]
l = 0
for (var i = 0; i < answer.length; i++) {
// console.log(parsed)
if (answer[i] == 'k') {
parsed[j] = parsed[j] * 1000
j++
multiple[l] = 1000
l++
}
else if (answer[i] == 'm') {
parsed[j] = parsed[j] * 1000000
j++
multiple[l] = 1000000
l++
}
else if (answer[i] == 'b') {
parsed[j] = parsed[j] * 1000000000
j++
multiple[l] = 1000000000
l++
}
else if (answer[i].includes('k', 'm', 'b') == false) {
parsed[j] = parseFloat(answer[i])
}
}
if (multiple[0] != multiple[1]){
if (multiple[0] == 0){
parsed[0] = parsed[0] * multiple[1]
}
if (multiple[1] == 0){
parsed[1] = parsed[1] * multiple[0]
}
}
return parsed
}
function scoreAnswer(key, parsedAnswer, factor) {
// had trouble with undefined when I used this function
lowerBound = parsedAnswer[0]
upperBound = parsedAnswer[1]
shift = (factor - 1) * (upperBound - lowerBound) / 2
// console.log(shift)
if (lowerBound - shift <= answerKey[key] && answerKey[key] <= upperBound + shift){
return 1
}
else {
return 0
}
// console.log(answer[0], answerKey[key], answer[1])
}
function scoreAnswers (factor){
score = 0
possibleScore = 0
accuracy = 1
for (var key in answerKey) {
if (answerKey.hasOwnProperty(key)) {
// console.log(key + " -> " + answerKey[key]);
var answer = urlParams.get(key)
if (answer != null){
var parsedAnswer = parseAnswer(urlParams.get(key))
// console.log(scoreAnswer(key, parsedAnswer, factor));
}
if (parsedAnswer != false && parsedAnswer != undefined) {
score += scoreAnswer(key, parsedAnswer, factor)
possibleScore ++
var lowerBound = parsedAnswer[0]
var upperBound = parsedAnswer[1]
// var geometricMean = Math.sqrt(upperBound * lowerBound)
if (upperBound / lowerBound > 0 && upperBound / lowerBound < 100000 ) {
accuracy = accuracy * (upperBound / lowerBound)
}
// var accuracy = accuracy * Math.max(geometricMean / answerKey[key], answerKey[key] / geometricMean)
// console.log(accuracy, lowerBound, upperBound, geometricMean, answerKey[key], key)
// }
}
}
}
accuracy = Math.pow(accuracy, 1 / possibleScore)
console.log(accuracy)
return [score, possibleScore, accuracy]
}
// var score, possibleScore
// console.log("possibleScore " + possibleScore)
// console.log("score " + score)
factors = [.1, .2, .3, .4, .5, .6, .7, .8, .9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.75, 2.0, 2.25, 2.5, 3, 4, 5, 6, 7, 8, 9]
function findBestFactor(factors){
var bestFactor = 10
var currentCalibration = 1
var bestResults = []
for (var i = 0; i < factors.length; i++) {
var factor = factors[i]
results = scoreAnswers(factor)
calibration = Math.abs(.8 - results[0]/results[1])
// console.log(Calibration, results)
// console.log(Calibration)
if (calibration < currentCalibration || (calibration = currentCalibration && Math.abs(1 - bestFactor) > Math.abs(1 - factor))){
// if it's closer to 80% or equal to current with a given factor and the factor is closer to 1 update
console.log(factor, results)
bestFactor = factor
currentCalibration = calibration
bestResults = results
}
}
return [bestFactor, bestResults[0]/bestResults[1]]
}
console.log(findBestFactor(factors))
// [score, possibleScore] = scoreAnswers(2.0)
// console.log("possibleScore " + possibleScore)
// console.log("score " + score)
// ad_spend=3 - What percent of Internet...&why_voice=4 - What percent of particip...&aws_growth=5 - By what percent did Amaz...&iphone_sales=6 - What percentage of Apple...&search_mkt=7 - What percentage of deskt...&slack_prod=8 - On average, how much mor...&airbnb_hilton=9 - What's the ratio between...&bitcoin_mktcap=10 - What was the market cap...
// console.log(parseAnswer("5b to 10m ?"))
// console.log(parseAnswer("5"))
// console.log(parseAnswer("5M - 10M"))
// console.log(parseAnswer("5B -10B"))
// console.log(parseAnswer("5k-10k"))
// console.log(parseAnswer("2-5%"))
// console.log(parseAnswer("5.2b to 10.7B ?"))
// - How many daily active us...&ad_spend=3 - What percent of Internet...&why_voice=4 - What percent of particip...&aws_growth=5 - By what percent did Amaz...&iphone_sales=6 - What percentage of Apple...&search_mkt=7 - What percentage of deskt...&slack_prod=8 - On average, how much mor...&airbnb_hilton=9 - What's the ratio between...&bitcoin_mktcap=10 - What was the market cap...
// param1 = 'netflix_pct'
// console.log(urlParams.get(param1))
$(document).ready(function(){
var results = scoreAnswers(1.0)
var score = results[0]
var possibleScore = results[1]
var factor_results = findBestFactor(factors)
var factor = +factor_results[0].toFixed(2)
var accuracy = results[2].toFixed(1)
$('#score').text(Math.round(100 * score / possibleScore) + "% of your answers were in your 80% confidence intervals")
if (score/possibleScore <= .65) {
$('#percent').text("No worries 50% is about average here at the start. But having your 80% predictions come true " + Math.round(100 * score / possibleScore) + "% of the time is pretty confusing to all parties involved, so we need to get you calibrated before predictions can be a powerful communication and prioritization tool for you.")
}
else if (score/possibleScore <= .90) {
$('#percent').text("Amazing! Your 80% predictions already come true about " + Math.round(100 * score / possibleScore) + "% of the time. At this point predictions are an extremely useful communication and planning tool.")
//TODO add advice on what kind of predictions to make steps here https://blog.twitch.tv/flash-forecasting-f8384cfe4f6c
}
else {
$('#percent').text("You are a rare bird, that is underconfident. Having your 80% predictions come true " + Math.round(100 * score / possibleScore) + "% of the time is a bit confusing to all parties involved, so we need to get you calibrated before predictions can be a powerful communication and prioritization tool for you.")
}
if (factor > 1) {
$('#factor').text("Make your confidence intervals " + factor + "x bigger" )
$('#factor_text').text("That would have made you well calibrated here (your 80% predictions come true approximately 80% of the time in reality). Once you are calibrated any confusion or awkwardness you have about probabilities and predictions should evaporate." )
}
else if (factor == 1) {
$('#factor').text("Don't change a thing" )
$('#factor_text').text("Trust in your 80% predictions. They lead to 80% in reality" )
}
else {
$('#factor').text("Make your confidence intervals " + factor + " as big" )
$('#factor_text').text("That would have made you well calibrated here (80% prediction => 80% in reality). Once you are calibrated any confusion or awkwardness you have about probabilities and predictions should evaporate." )
}
$('#accuracy').text("Your upper bounds were " + accuracy + "x your lower bounds" )
$('#accuracy_text').text("(On average). Being calibrated is the low hanging fruit of predicting the future, but being able to predict something will fit into a narrow band of outcomes (accuracy) is incredibly valuable. Gaining accuracy in the domains you actually care about is a life long pursuit. Calibration specific to your domain/org might be answer here. We could build that together. [email protected]" )
})
</script>
<canvas height='1' id='confetti' width='1'> </canvas>
<div class="wrapper">
<div class="intro">
<div class="logo">
<img src="[email protected]">
</div>
<!-- <h2>You rock! </span></h2> -->
<section class="share">
<!-- <h1>You rock!</h1> -->
<h2>Predicting the future can be scary and intense, but you are well on your way. Don't leave your friends behind</h2>
<div class="share-buttons">
<a class="share-button fb js-share-fb">
<i class="fa fa-facebook-official" aria-hidden="true"></i>
Share it
</a>
<a class="share-button twitter js-share-twitter">
<i class="fa fa-twitter" aria-hidden="true"></i>
Tweet it
</a>
</div>
</section>
</div>
<section class="steps">
<h2>Your Results</h2>
<div class="step">
<div class="step__number"></div>
<div class="step__content">
<div class="step__headline" id=score></div>
<div class="step__detail" id=percent></div>
</div>
</div>
<div class="step">
<div class="step__number"></div>
<div class="step__content">
<div class="step__headline" id=factor></div>
<div class="step__detail" id=factor_text></div>
</div>
</div>
<div class="step">
<div class="step__number"></div>
<div class="step__content">
<div class="step__headline" id=accuracy></div>
<div class="step__detail" id=accuracy_text></a>. </div>
</div>
</div>
<br>
<br>
<h2>Leverage Predictions in your day to day</h2>
<div class="step__detail">
<p>At the one end I recommend you start making predictions on the impact your most important and exciting projects
will have (at least quarterly). Better decisions, understanding, and communication on those projects are very high leverage.
<p>At the other end I recommend you use predictions to become reliable. Whenever you make committments,
ask yourself am I at least 80% confident I'll follow through here? When I'm not, I renegotiate immediately:
Actually I expect I can have that for you in 3 weeks, 1 was optimistic. Actually I can't commit to do that at all
because I'm super focused on x and y right now. The earlier you reset expectations the better. It's pretty easy to get other people
to clarify their committments in the same way. How surprised would they be if they didn't deliver that dependency on your critical path? You probably want an 80 or 90% commitment here.
<a href="https://blog.twitch.tv/flash-forecasting-f8384cfe4f6c"> More on that written up here. </a>
I can also help directly! ([email protected])
<p>Good Times,
<br>Danny Hernandez
<br>
<br>
<br>
<br>
</div>
</section>
</div>
</body>
</html>