-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBayes_advantage.html
More file actions
728 lines (650 loc) · 35.2 KB
/
Copy pathBayes_advantage.html
File metadata and controls
728 lines (650 loc) · 35.2 KB
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
<!DOCTYPE html>
<html lang="de" data-theme="dark">
<head>
<meta charset="UTF-8">
<script>(function(){var t=localStorage.getItem('btl-theme');if(t)document.documentElement.setAttribute('data-theme',t);if(t==='light')document.addEventListener('DOMContentLoaded',function(){['btn-theme','btn-th','btn-th-nav','themeBtn'].forEach(function(id){var b=document.getElementById(id);if(b)b.textContent='🌙 Dark';});});})()</script>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="Warum Bayesianische Parameterschätzung? Direktes Antworten auf Wahrscheinlichkeitsfragen — interaktiv erkunden.">
<meta property="og:title" content="Warum Bayes? — Bayes Thinking Lab">
<meta property="og:type" content="website">
<title>Warum Bayes? — Bayes Thinking Lab</title>
<link href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,400;0,500;1,400&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,600;1,9..144,300;1,9..144,400&display=swap" rel="stylesheet">
<style>
:root{
--bg:#f2ede3;--paper:#faf6ee;--ink:#18130e;--ink2:#5a4f42;
--a1:#c94a2a;--a2:#2a6e8a;--a3:#58407B;--a4:#7a3a8a;--a5:#b85c00;--a6:#0e7c7b;
--prior-color:#5a8a2a;
--grid:#ddd5c6;--panel:#ece5d5;--border:#c5bba8;
}
[data-theme="dark"]{
--bg:#0f1117;--paper:#171b25;--ink:#e8e2d8;--ink2:#9a9080;
--a1:#e8614a;--a2:#4ab0d8;--a3:#7959A8;--a4:#c87ad8;--a5:#e07830;--a6:#2bc7c4;
--prior-color:#80cb52;
--grid:#252a36;--panel:#1e2230;--border:#333a4a;
}
*{box-sizing:border-box;margin:0;padding:0}
html{font-size:18px}
body{font-family:'Fraunces',Georgia,serif;background:var(--bg);color:var(--ink);
height:100vh;overflow:hidden;display:flex;flex-direction:column;transition:background .25s,color .25s}
/* ── HEADER (einheitlich, identisch zu Bayesian_model_architect) ── */
#topbar{background:var(--paper);border-bottom:1.5px solid var(--border);
padding:.5rem 1.1rem;display:flex;align-items:center;justify-content:space-between;flex-shrink:0;gap:.5rem;line-height:normal}
.hdr-h1{font-family:'Fraunces',Georgia,serif;font-size:1.55rem;font-weight:300;letter-spacing:-.02em;line-height:1.2}
.hdr-h1 em{font-style:italic;color:var(--a3)}
.hdr-sub2{font-family:'DM Mono',monospace;font-size:.75rem;color:var(--ink2);margin-top:.2rem;letter-spacing:.03em}
.hdr-auth{font-family:'DM Mono',monospace;font-size:.75rem;color:var(--ink2);opacity:.5;margin-top:.1rem}
.hdr-btns{display:flex;gap:.4rem;align-items:center}
.hbtn{font-family:'DM Mono',monospace;font-size:.75rem;background:var(--panel);border:1.5px solid var(--border);color:var(--ink2);padding:.22rem .6rem;cursor:pointer;transition:all .15s}
.hbtn:hover{border-color:var(--a2);color:var(--a2)}
.hbtn.act{background:var(--a2);color:var(--paper);border-color:var(--a2)}
.glo-link{color:inherit;text-decoration:underline;text-decoration-style:dotted;text-underline-offset:3px;cursor:pointer}
.glo-link:hover{color:var(--a2)}
#shell{flex:1;overflow-y:auto;min-height:0}
/* LAYOUT */
#wrap{max-width:1100px;margin:0 auto;padding:1.5rem 2rem 4rem}
/* SCENARIO STRIP */
.scenario-strip{background:var(--panel);border:1px solid var(--border);
padding:.6rem 1.1rem;margin-bottom:1.5rem;
display:flex;align-items:center;gap:.8rem;flex-wrap:wrap;
font-family:'DM Mono',monospace;font-size:.75rem;color:var(--ink2)}
.stag{font-size:.75rem;letter-spacing:.1em;text-transform:uppercase;
padding:.1rem .4rem;border:1px solid var(--a5);color:var(--a5);flex-shrink:0}
/* ACT HEADER */
.act{margin-bottom:3rem}
.act-hdr{display:flex;align-items:center;gap:.8rem;margin-bottom:1rem;
padding-bottom:.5rem;border-bottom:2px solid var(--grid)}
.act-num{font-family:'DM Mono',monospace;font-size:.75rem;letter-spacing:.12em;
text-transform:uppercase;padding:.18rem .55rem;border:1.5px solid;white-space:nowrap}
.act-num.c3{border-color:var(--a3);color:var(--a3)}
.act-num.c2{border-color:var(--a2);color:var(--a2)}
.act-title{font-size:1.15rem;font-weight:600;letter-spacing:-.02em}
.act-title em{font-style:italic}
/* HELP TOGGLE */
.htoggle{font-family:'DM Mono',monospace;font-size:.75rem;padding:.2rem .65rem;
border:1.5px solid var(--a1);background:transparent;cursor:pointer;
color:var(--a1);transition:all .15s;margin-left:auto;white-space:nowrap;flex-shrink:0}
.htoggle:hover,.htoggle.open{background:var(--a1);color:var(--paper);border-color:var(--a1)}
/* HELP PANEL (dropdown) */
.help-panel{display:none;gap:1px;background:var(--grid);margin-bottom:1px}
.help-panel.open{display:grid;grid-template-columns:1fr 1fr}
.hcard{background:var(--panel);padding:.75rem 1rem}
.hcard-h{font-family:'DM Mono',monospace;font-size:.72rem;letter-spacing:.1em;
text-transform:uppercase;color:var(--a3);margin-bottom:.35rem;
padding-bottom:.2rem;border-bottom:1px solid var(--grid)}
.hcard-body{font-family:'DM Mono',monospace;font-size:.75rem;color:var(--ink2);
line-height:1.75}
.hcard-body strong{color:var(--ink)}
/* ACT 1 — TWO PANELS */
.act1-grid{display:grid;grid-template-columns:340px 1fr;gap:1px;
background:var(--grid);margin-bottom:1px}
.a1-panel{background:var(--paper)}
.panel-lbl{font-family:'DM Mono',monospace;font-size:.75rem;letter-spacing:.1em;
text-transform:uppercase;padding:.7rem 1.1rem .4rem;
border-bottom:1px solid var(--grid)}
.panel-lbl.freq{color:var(--a1)}
.panel-lbl.bayes{color:var(--a2)}
/* FREQ OUTPUT */
.freq-box{padding:.9rem 1.1rem;font-family:'DM Mono',monospace;font-size:.82rem;
line-height:2;color:var(--ink)}
.fk{color:var(--ink2)}
.fv{font-weight:500}
.fsep{border:none;border-top:1px solid var(--grid);margin:.6rem 0}
.f-limit{display:flex;align-items:center;gap:.45rem;padding:.1rem 0;font-size:.78rem}
.f-cross{color:var(--a1)}
.f-q{color:var(--ink)}
.f-note{color:var(--a1);font-size:.7rem;opacity:.85}
/* BAYES PANEL CANVAS */
.canvas-wrap{position:relative;cursor:ew-resize;line-height:0}
canvas{display:block;width:100%;height:auto}
.prob-overlay{position:absolute;top:.9rem;right:1rem;
font-family:'DM Mono',monospace;text-align:right;pointer-events:none;
user-select:none}
.prob-big{font-size:2.6rem;font-weight:500;line-height:1;color:var(--a2)}
.prob-sub{font-size:.78rem;color:var(--ink2);margin-top:.25rem}
.drag-hint{font-family:'DM Mono',monospace;font-size:.75rem;color:var(--ink2);
opacity:.55;text-align:center;padding:.3rem;background:var(--panel)}
/* Q STRIP */
.q-strip{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1px;background:var(--grid)}
.q-cell{background:var(--paper);padding:.9rem 1rem}
.q-question{font-family:'DM Mono',monospace;font-size:.75rem;color:var(--ink2);
margin-bottom:.55rem;line-height:1.6}
.q-thresh-val{color:var(--a3);font-weight:500}
.q-freq{font-family:'DM Mono',monospace;font-size:.75rem;color:var(--a1);
margin-bottom:.3rem;display:flex;align-items:flex-start;gap:.35rem}
.q-bayes{font-family:'DM Mono',monospace;font-size:.82rem;color:var(--a2);
font-weight:500;display:flex;align-items:flex-start;gap:.35rem}
.q-bayes b{color:var(--a2)}
/* ACT 2 PRIOR SELECTOR */
.prior-sel{display:flex;gap:2px;background:var(--grid);margin-bottom:1px}
.pbtn{flex:1;font-family:'DM Mono',monospace;font-size:.75rem;
padding:.65rem .9rem;background:var(--panel);border:none;cursor:pointer;
color:var(--ink2);text-align:left;transition:all .15s;
border-bottom:2.5px solid transparent}
.pbtn:hover{background:var(--paper);color:var(--ink)}
.pbtn.sel{background:var(--paper);color:var(--a3);border-bottom-color:var(--a3)}
.pbtn .pb-name{display:block;font-weight:500;margin-bottom:.12rem}
.pbtn .pb-meta{display:block;font-size:.7rem;opacity:.7}
/* CUSTOM SLIDERS */
.slider-row{background:var(--panel);border-bottom:1px solid var(--grid);
padding:.65rem 1.1rem;display:flex;align-items:center;gap:.9rem;flex-wrap:wrap;
font-family:'DM Mono',monospace;font-size:.75rem;color:var(--ink2)}
.slider-row input[type=range]{flex:1;min-width:80px;accent-color:var(--a3)}
.sv{color:var(--a3);font-weight:500;min-width:2.8rem}
/* ACT 2 CANVAS */
.a2-wrap{background:var(--paper);position:relative;line-height:0}
/* CRI COMPARISON */
.cri-compare{display:grid;grid-template-columns:1fr 1fr 1fr;
gap:1px;background:var(--grid);margin-bottom:1px}
.cri-cell{background:var(--paper);padding:.8rem 1rem}
.cri-lbl{font-family:'DM Mono',monospace;font-size:.75rem;margin-bottom:.5rem}
.cri-track{height:12px;background:var(--bg);position:relative;margin-bottom:.4rem;
border:1px solid var(--grid)}
.cri-fill{height:100%;position:absolute;left:0;top:0;opacity:.85;
transition:width .4s ease}
.cri-nums{font-family:'DM Mono',monospace;font-size:.78rem;font-weight:500}
.cri-w{font-family:'DM Mono',monospace;font-size:.7rem;color:var(--ink2);margin-top:.15rem}
/* MESSAGE */
.msg{background:var(--panel);border:1px solid var(--border);
padding:.85rem 1.2rem;display:flex;align-items:flex-start;gap:.85rem;
font-family:'DM Mono',monospace;font-size:.78rem;line-height:1.7}
.msg-arrow{color:var(--a3);font-size:1.3rem;flex-shrink:0;margin-top:.05rem}
.msg strong{color:var(--ink)}
.msg span{color:var(--ink2)}
/* SCALE NOTE */
.scale-note{font-family:'DM Mono',monospace;font-size:.72rem;color:var(--ink2);
padding:.3rem 1rem;background:var(--panel);border-bottom:1px solid var(--grid);
display:flex;align-items:center;gap:.4rem}
.scale-note strong{color:var(--a5)}
@media(max-width:720px){
.act1-grid{grid-template-columns:1fr}
.q-strip{grid-template-columns:1fr}
.cri-compare{grid-template-columns:1fr}
.help-panel.open{grid-template-columns:1fr}
#wrap{padding:1rem}
}
</style>
</head>
<body>
<div id="topbar">
<div>
<div class="hdr-h1"><em>Warum Bayes?</em> — Parameterschätzung neu gedacht</div>
<div class="hdr-sub2">Gleiche Daten · mehr Antworten · kumulatives Wissen</div>
<div class="hdr-auth">© Dr. Rainer Düsing · Interactive Tools by Claude</div>
</div>
<div class="hdr-btns">
<button class="hbtn" onclick="location.href='index_de.html'" style="border-color:var(--a3);color:var(--a3)">← Übersicht</button>
<button class="hbtn" id="btn-theme" onclick="toggleTheme()">☀ Light</button>
</div>
</div>
<main id="shell">
<div id="wrap">
<div class="scenario-strip">
<span class="stag">Szenario</span>
<span>
<b>KVT-Studie:</b> n = 40 · Outcome: BDI-Reduktion (Punkte) · Therapie vs. Kontrolle
· β̂ = 4.80, SE = 2.10
</span>
</div>
<!-- ═══ ACT 1 ═══════════════════════════════════════════════════════ -->
<section class="act">
<div class="act-hdr">
<span class="act-num c3">Akt 1</span>
<span class="act-title">Gleiche Daten — <em style="color:var(--a3)">andere Fragen möglich</em></span>
<button class="htoggle" id="h1btn" onclick="toggleHelp(1)">? Hilfe ▸</button>
</div>
<div class="help-panel" id="help1">
<div class="hcard">
<div class="hcard-h">Was sehe ich?</div>
<div class="hcard-body">Die <strong><a class="glo-link" href="Glossar.html#gl-posterior" target="_blank" title="Der Posterior p(θ|D) ist die Wahrscheinlichkeitsverteilung über die Modellparameter θ nach Betrachtung der Daten D." style="color:inherit">Posterior</a>-Verteilung von β</strong> — die Plausibilität aller Effektgrößen gegeben Vorwissen (<a class="glo-link" href="Glossar.html#gl-prior" target="_blank" title="Der Prior p(θ) ist die Wahrscheinlichkeitsverteilung über Modellparameter θ, die unser Vorwissen vor Betrachtung der Daten ausdrückt.">Prior</a>) und Daten. Die blaue Fläche rechts der Schwelle zeigt, wie viel Wahrscheinlichkeitsmasse auf diesem Bereich liegt.</div>
</div>
<div class="hcard">
<div class="hcard-h">Was soll ich tun?</div>
<div class="hcard-body"><strong>Schwelle mit der Maus ziehen</strong> und dabei überlegen: Ab welchem β-Wert ist der Effekt klinisch bedeutsam? Z. B. 2.2 oder 5.0 BDI-Punkte — der Grenzwert ist frei wählbar.</div>
</div>
<div class="hcard">
<div class="hcard-h">Wie interpretiere ich das?</div>
<div class="hcard-body">Die Prozentzahl = P(β > Schwelle | Daten, Prior) — eine <strong>direkte Wahrscheinlichkeitsaussage über den Parameter</strong>. Mehrere Schwellen ausprobieren ist kein Problem: der Posterior ändert sich nicht, nur die Abfrage.</div>
</div>
<div class="hcard">
<div class="hcard-h">Warum kann das Frequentismus nicht?</div>
<div class="hcard-body">Das 95%-<a class="glo-link" href="Glossar.html#gl-konfidenzintervall" target="_blank" title="Ein 95%-Konfidenzintervall ist ein Intervall, das bei wiederholter Anwendung der Schätzmethode in 95% der Fälle den wahren Parameterwert enthält — eine Aussage über das Verfahren, nicht über einen bestimmten Parameter.">KI</a> ist <strong>keine</strong> Wahrscheinlichkeitsaussage über β. P(β > 3) lässt sich nicht direkt ablesen. Wer denselben Datensatz auf β > 3 <em>und</em> β > 2.2 testet, begeht <strong>multiples Testen</strong> mit erhöhter Fehlerrate. Bayesianisch kein Problem: der Posterior ist fix.</div>
</div>
</div>
<div class="act1-grid">
<!-- LEFT: FREQUENTIST -->
<div class="a1-panel">
<div class="panel-lbl freq">Frequentistisch</div>
<div class="freq-box">
<div><span class="fk">β̂ =</span> <span class="fv">4.80</span> <span class="fk">SE =</span> <span class="fv">2.10</span></div>
<div><span class="fk">95% <a class="glo-link" href="Glossar.html#gl-konfidenzintervall" target="_blank" title="Ein 95%-Konfidenzintervall ist ein Intervall, das bei wiederholter Anwendung der Schätzmethode in 95% der Fälle den wahren Parameterwert enthält." style="color:inherit">KI</a>: </span><span class="fv">[0.68, 8.92]</span></div>
<div><span class="fk">t(38) =</span> <span class="fv">2.29</span> <span class="fk">p =</span> <span class="fv">.023</span></div>
<hr class="fsep">
<div class="f-limit">
<span class="f-cross">✗</span>
<span class="f-q">P(β > 3) = ?</span>
<span class="f-note">kein direktes Ergebnis</span>
</div>
<div class="f-limit">
<span class="f-cross">✗</span>
<span class="f-q">P(β > 0) = ?</span>
<span class="f-note">kein direktes Ergebnis</span>
</div>
<div class="f-limit">
<span class="f-cross">✗</span>
<span class="f-q">P(2 < β < 7) = ?</span>
<span class="f-note">kein direktes Ergebnis</span>
</div>
</div>
</div>
<!-- RIGHT: POSTERIOR CANVAS -->
<div class="a1-panel">
<div class="panel-lbl bayes">
Bayes — Posterior-Verteilung
<span style="font-size:.7rem;opacity:.55;font-weight:400"> (Schwelle mit Maus verschieben)</span>
</div>
<div class="canvas-wrap" id="a1wrap">
<canvas id="a1c" width="700" height="280"></canvas>
<div class="prob-overlay">
<div class="prob-big" id="probBig">—</div>
<div class="prob-sub" id="probSub">P(β > <span id="tDisp">3.0</span>)</div>
</div>
</div>
<div class="drag-hint">← Schwelle ziehen →</div>
</div>
</div><!-- /act1-grid -->
<!-- QUESTIONS -->
<div class="q-strip">
<div class="q-cell">
<div class="q-question">Ist der Effekt klinisch bedeutsam<br>(≥ <span class="q-thresh-val" id="qThreshText">3.0</span> BDI-Punkte)?</div>
<div class="q-freq"><span>✗</span><span>Frequentistisch: nicht direkt — p = .023 sagt nur: „signifikant"</span></div>
<div class="q-bayes"><span>✓</span><span id="qa1">P(β > 3.0) = <b>—</b></span></div>
</div>
<div class="q-cell">
<div class="q-question">Mit welcher Wahrsch. ist der Effekt<br>überhaupt positiv?</div>
<div class="q-freq"><span>✗</span><span>p < .05 beantwortet das nicht</span></div>
<div class="q-bayes"><span>✓</span><span id="qa2">P(β > 0) = <b>—</b></span></div>
</div>
<div class="q-cell">
<div class="q-question">Liegt der Effekt im praktisch<br>relevanten Bereich [2, 7]?</div>
<div class="q-freq"><span>✗</span><span>KI enthält mehr als diesen Bereich</span></div>
<div class="q-bayes"><span>✓</span><span id="qa3">P(2 < β < 7) = <b>—</b></span></div>
</div>
</div>
</section>
<!-- ═══ ACT 2 ═══════════════════════════════════════════════════════ -->
<section class="act">
<div class="act-hdr">
<span class="act-num c2">Akt 2</span>
<span class="act-title">Prior als <em style="color:var(--a2)">kumulatives Wissen</em></span>
<button class="htoggle" id="h2btn" onclick="toggleHelp(2)">? Hilfe ▸</button>
</div>
<div class="help-panel" id="help2">
<div class="hcard">
<div class="hcard-h">Was sehe ich?</div>
<div class="hcard-body">Drei Kurven: <strong style="color:var(--prior-color)"><a class="glo-link" href="Glossar.html#gl-prior" target="_blank" title="Der Prior p(θ) ist die Wahrscheinlichkeitsverteilung über Modellparameter θ, die unser Vorwissen vor Betrachtung der Daten ausdrückt." style="color:inherit">Prior</a></strong> (grün, gestrichelt — Vorwissen vor den Daten), <strong style="color:var(--a5)"><a class="glo-link" href="Glossar.html#gl-likelihood" target="_blank" title="Die Likelihood-Funktion L(θ; D) beschreibt, wie wahrscheinlich die beobachteten Daten D unter verschiedenen Parameterwerten θ wären." style="color:inherit">Likelihood</a></strong> (orange, gepunktet — was die Daten allein sagen) und <strong style="color:var(--a2)"><a class="glo-link" href="Glossar.html#gl-posterior" target="_blank" title="Der Posterior p(θ|D) ist die Wahrscheinlichkeitsverteilung über die Modellparameter θ nach Betrachtung der Daten D." style="color:inherit">Posterior</a></strong> (blau, gefüllt — kombiniertes Ergebnis). Darunter ein Breitenvergleich der 95%-Intervalle.</div>
</div>
<div class="hcard">
<div class="hcard-h">Was soll ich tun?</div>
<div class="hcard-body">Zwischen <strong>uninformativem</strong> und <strong>informativem Prior</strong> wechseln. Die Likelihood (Daten) bleibt dabei identisch — nur der Prior ändert sich und damit der Posterior.</div>
</div>
<div class="hcard">
<div class="hcard-h">Wie interpretiere ich das?</div>
<div class="hcard-body">Mit informativem Prior (10 Vorstudien: μ = 5, σ = 0.6) zieht der Posterior zusammen. <strong>Gleiche Daten, präziserer Posterior</strong> — das Vorwissen reduziert die Unsicherheit formal und transparent.</div>
</div>
<div class="hcard">
<div class="hcard-h">Warum ist das gut?</div>
<div class="hcard-body">Frequentismus ignoriert Vorwissen strukturell. Bayes formalisiert kumulatives Lernen: <strong>der Posterior von heute ist der Prior von morgen.</strong> Wissenschaftlicher Fortschritt als akkumulierter Wissensstand.</div>
</div>
<div class="hcard">
<div class="hcard-h">Weiterführende Literatur</div>
<div class="hcard-body"><a class="glo-link" href="Referenzen.html#ref-kruschke-2014" target="_blank">Kruschke (2014)</a> — HDI/ROPE-Entscheidungslogik<br><a class="glo-link" href="Referenzen.html#ref-mcelreath-2020" target="_blank">McElreath (2020)</a> — Bayesianischer Workflow, Prior als kumulatives Wissen</div>
</div>
</div>
<div class="prior-sel" id="priorSel">
<button class="pbtn sel" onclick="setPrior('flat',this)">
<span class="pb-name">Uninformativer Prior</span>
<span class="pb-meta">Tabula rasa — alle Effekte gleich plausibel</span>
</button>
<button class="pbtn" onclick="setPrior('informed',this)">
<span class="pb-name">Informativer Prior</span>
<span class="pb-meta">10 Vorstudien: μ = 5, σ = 0.6 — kumulatives Wissen</span>
</button>
<button class="pbtn" onclick="setPrior('custom',this)">
<span class="pb-name">Eigener Prior</span>
<span class="pb-meta">μ und σ selbst wählen</span>
</button>
</div>
<div class="slider-row" id="customRow" style="display:none">
<label>Prior μ:</label>
<input type="range" id="slMu" min="-5" max="15" step="0.5" value="0" oninput="updateCustom()">
<span class="sv" id="svMu">0.0</span>
<label style="margin-left:.5rem">Prior σ:</label>
<input type="range" id="slSig" min="0.3" max="10" step="0.1" value="5" oninput="updateCustom()">
<span class="sv" id="svSig">5.0</span>
</div>
<div class="a2-wrap">
<canvas id="a2c" width="1000" height="320"></canvas>
</div>
<div class="scale-note">
Hinweis: <strong><a class="glo-link" href="Glossar.html#gl-likelihood" target="_blank" title="Die Likelihood-Funktion L(θ; D) beschreibt, wie wahrscheinlich die beobachteten Daten D unter verschiedenen Parameterwerten θ wären." style="color:inherit">Likelihood</a> (orange) bleibt bei allen <a class="glo-link" href="Glossar.html#gl-prior" target="_blank" title="Der Prior p(θ) ist die Wahrscheinlichkeitsverteilung über Modellparameter θ, die unser Vorwissen vor Betrachtung der Daten ausdrückt." style="color:inherit">Priors</a> konstant.</strong>
<span style="margin-left:.3rem">Die Y-Achse skaliert auf die höchste Kurve — daher wirkt sie kleiner, wenn Prior oder Posterior schmäler und damit höher wird.</span>
</div>
<div class="cri-compare">
<div class="cri-cell">
<div class="cri-lbl" style="color:var(--a1)">Frequentistisch — 95% <a class="glo-link" href="Glossar.html#gl-konfidenzintervall" target="_blank" title="Ein 95%-Konfidenzintervall ist ein Intervall, das bei wiederholter Anwendung der Schätzmethode in 95% der Fälle den wahren Parameterwert enthält." style="color:inherit">KI</a></div>
<div class="cri-track"><div class="cri-fill" id="bFreq" style="background:var(--a1);width:100%"></div></div>
<div class="cri-nums" style="color:var(--a1)">[0.68, 8.92]</div>
<div class="cri-w">Breite: 8.24 Punkte</div>
</div>
<div class="cri-cell">
<div class="cri-lbl" style="color:var(--a2)">Bayes — uninformativer Prior</div>
<div class="cri-track"><div class="cri-fill" id="bFlat" style="background:var(--a2);width:100%"></div></div>
<div class="cri-nums" style="color:var(--a2)">[0.68, 8.92]</div>
<div class="cri-w">Breite: 8.24 Punkte</div>
</div>
<div class="cri-cell">
<div class="cri-lbl" id="criLbl" style="color:var(--a3)">Bayes — informativer Prior (10 Studien)</div>
<div class="cri-track"><div class="cri-fill" id="bInf" style="background:var(--a3);width:27%"></div></div>
<div class="cri-nums" id="criNums" style="color:var(--a3)">[3.86, 6.12]</div>
<div class="cri-w" id="criW">Breite: 2.26 Punkte <b style="color:var(--a3)">↓ 73% schmäler</b></div>
</div>
</div>
<div class="msg">
<span class="msg-arrow">→</span>
<span>
<strong>Frequentismus hat keinen formalen Mechanismus für Vorwissen.</strong>
Mit einem informativen Prior — hier aus 10 Vorstudien abgeleitet — wird der <a class="glo-link" href="Glossar.html#gl-posterior" target="_blank" title="Der Posterior p(θ|D) ist die Wahrscheinlichkeitsverteilung über die Modellparameter θ nach Betrachtung der Daten D.">Posterior</a>
deutlich präziser: gleiche Daten, schmaleres Intervall.
Das ist kumulatives Lernen in der Wissenschaft.
</span>
</div>
</section>
</div><!-- /wrap -->
</main>
<script>
// ── THEME ──────────────────────────────────────────────────────
function toggleTheme(){
const d = document.documentElement;
const dark = d.getAttribute('data-theme') === 'dark';
d.setAttribute('data-theme', dark ? 'light' : 'dark');
document.getElementById('btn-theme').textContent = dark ? '🌙 Dark' : '☀ Light';
localStorage.setItem('btl-theme', dark ? 'light' : 'dark');
drawA1(); drawA2();
}
function cv(v){ return getComputedStyle(document.documentElement).getPropertyValue(v).trim(); }
// ── MATH ──────────────────────────────────────────────────────
function npdf(x, mu, s){ return Math.exp(-0.5*((x-mu)/s)**2) / (s*Math.sqrt(2*Math.PI)); }
function ncdf(x, mu, s){ return 0.5*(1 + erf((x-mu)/(s*Math.SQRT2))); }
function erf(x){
const a1=0.254829592, a2=-0.284496736, a3=1.421413741, a4=-1.453152027, a5=1.061405429, p=0.3275911;
const sgn = x<0?-1:1; x = Math.abs(x);
const t = 1/(1+p*x);
return sgn*(1 - (((((a5*t+a4)*t+a3)*t+a2)*t+a1)*t)*Math.exp(-x*x));
}
function postParams(prMu, prSig){
const lMu=4.80, lSig=2.10;
if(prSig > 60) return {mu:lMu, sig:lSig};
const pv = 1/(1/prSig**2 + 1/lSig**2);
const pm = pv*(prMu/prSig**2 + lMu/lSig**2);
return {mu:pm, sig:Math.sqrt(pv)};
}
function priorForMode(){
if(A2.mode==='flat') return {mu:0, sig:100};
if(A2.mode==='informed') return {mu:5, sig:0.6};
return {mu:A2.cMu, sig:A2.cSig};
}
// ── ACT 1 STATE ────────────────────────────────────────────────
const A1 = { thresh: 3.0 };
function drawA1(){
const canvas = document.getElementById('a1c');
const wrap = document.getElementById('a1wrap');
const W = wrap.clientWidth || 700, H = 280;
canvas.width = W; canvas.height = H;
const ctx = canvas.getContext('2d');
const mu=4.80, sig=2.10;
const xMin=-2, xMax=13;
const pL=52, pR=20, pT=28, pB=38;
const pw=W-pL-pR, ph=H-pT-pB;
const xc = x => pL + (x-xMin)/(xMax-xMin)*pw;
const yc = (y,mx) => pT + (1-y/mx)*ph;
const peak = npdf(mu,mu,sig)*1.18;
ctx.fillStyle = cv('--paper');
ctx.fillRect(0,0,W,H);
// x-grid
ctx.strokeStyle = cv('--grid'); ctx.lineWidth=1;
for(let x=0; x<=12; x+=2){
ctx.beginPath(); ctx.moveTo(xc(x),pT); ctx.lineTo(xc(x),pT+ph); ctx.stroke();
}
// shaded area right of threshold
const T = A1.thresh;
ctx.beginPath();
const step = (xMax-T)/200;
ctx.moveTo(xc(T), yc(0,peak));
for(let i=0;i<=200;i++){
const x=T+i*step;
ctx.lineTo(xc(x), yc(npdf(x,mu,sig),peak));
}
ctx.lineTo(xc(xMax), yc(0,peak));
ctx.closePath();
ctx.fillStyle = cv('--a2')+'88';
ctx.fill();
// main curve
ctx.beginPath();
for(let i=0;i<=300;i++){
const x=xMin+(xMax-xMin)*i/300;
i===0 ? ctx.moveTo(xc(x),yc(npdf(x,mu,sig),peak))
: ctx.lineTo(xc(x),yc(npdf(x,mu,sig),peak));
}
ctx.strokeStyle=cv('--a2'); ctx.lineWidth=2.5; ctx.stroke();
// threshold line
const tx=xc(T);
ctx.setLineDash([5,4]);
ctx.beginPath(); ctx.moveTo(tx,pT); ctx.lineTo(tx,pT+ph);
ctx.strokeStyle=cv('--a3'); ctx.lineWidth=2; ctx.stroke();
ctx.setLineDash([]);
// threshold label
ctx.fillStyle=cv('--a3');
ctx.font=`500 13px 'DM Mono',monospace`;
ctx.textAlign='center';
ctx.fillText('β = '+T.toFixed(1), tx, pT-8);
// x-axis
ctx.strokeStyle=cv('--border'); ctx.lineWidth=1;
ctx.beginPath(); ctx.moveTo(pL,pT+ph); ctx.lineTo(pL+pw,pT+ph); ctx.stroke();
ctx.fillStyle=cv('--ink2');
ctx.font=`400 12px 'DM Mono',monospace`;
ctx.textAlign='center';
for(let x=0; x<=12; x+=2){
const cx=xc(x);
ctx.beginPath(); ctx.moveTo(cx,pT+ph); ctx.lineTo(cx,pT+ph+5);
ctx.strokeStyle=cv('--border'); ctx.lineWidth=1; ctx.stroke();
ctx.fillText(x, cx, pT+ph+17);
}
ctx.fillText('β (BDI-Punkte)', pL+pw/2, H-3);
// update overlays
const prob = (1-ncdf(T,mu,sig))*100;
document.getElementById('probBig').textContent = prob.toFixed(1)+'%';
document.getElementById('tDisp').textContent = T.toFixed(1);
document.getElementById('qThreshText').textContent = T.toFixed(1);
document.getElementById('qa1').innerHTML =
'P(β > '+T.toFixed(1)+') = <b>'+prob.toFixed(1)+'%</b>';
}
function initA1Drag(){
const canvas = document.getElementById('a1c');
let drag=false;
function xFrom(e){
const r = canvas.getBoundingClientRect();
const px = (e.clientX - r.left)*(canvas.width/r.width);
const xMin=-2, xMax=13, pL=52, pR=20;
const pw = canvas.width - pL - pR;
return xMin + (px-pL)/pw*(xMax-xMin);
}
function set(e){ A1.thresh = Math.max(-1, Math.min(11, xFrom(e))); drawA1(); }
canvas.addEventListener('mousedown', e=>{ drag=true; set(e); });
canvas.addEventListener('mousemove', e=>{ if(drag) set(e); });
canvas.addEventListener('mouseup', ()=>drag=false);
canvas.addEventListener('mouseleave', ()=>drag=false);
canvas.addEventListener('touchstart', e=>{ drag=true; set(e.touches[0]); e.preventDefault(); },{passive:false});
canvas.addEventListener('touchmove', e=>{ if(drag) set(e.touches[0]); e.preventDefault(); },{passive:false});
canvas.addEventListener('touchend', ()=>drag=false);
}
function fillQ2Q3(){
const mu=4.80, sig=2.10;
const p0 = ((1-ncdf(0,mu,sig))*100).toFixed(1);
const p27 = ((ncdf(7,mu,sig)-ncdf(2,mu,sig))*100).toFixed(1);
document.getElementById('qa2').innerHTML = 'P(β > 0) = <b>'+p0+'%</b>';
document.getElementById('qa3').innerHTML = 'P(2 < β < 7) = <b>'+p27+'%</b>';
}
// ── ACT 2 STATE ────────────────────────────────────────────────
const A2 = { mode:'flat', cMu:0, cSig:5 };
function setPrior(mode, btn){
A2.mode = mode;
document.querySelectorAll('.pbtn').forEach(b=>b.classList.remove('sel'));
btn.classList.add('sel');
document.getElementById('customRow').style.display = mode==='custom' ? 'flex' : 'none';
drawA2(); updateCRI();
}
function updateCustom(){
A2.cMu = parseFloat(document.getElementById('slMu').value);
A2.cSig = parseFloat(document.getElementById('slSig').value);
document.getElementById('svMu').textContent = A2.cMu.toFixed(1);
document.getElementById('svSig').textContent = A2.cSig.toFixed(1);
drawA2(); updateCRI();
}
function drawA2(){
const canvas = document.getElementById('a2c');
const W = canvas.parentElement.clientWidth || 1000, H = 320;
canvas.width=W; canvas.height=H;
const ctx = canvas.getContext('2d');
const pr = priorForMode();
const lMu=4.80, lSig=2.10;
const po = postParams(pr.mu, pr.sig);
const xMin=-6, xMax=18;
const pL=52, pR=20, pT=32, pB=38;
const pw=W-pL-pR, ph=H-pT-pB;
const xc = x => pL+(x-xMin)/(xMax-xMin)*pw;
const yc = (y,mx) => pT+(1-y/mx)*ph;
const poMax = npdf(po.mu, po.mu, po.sig);
const lMax = npdf(lMu, lMu, lSig);
const prMax = pr.sig>60 ? 0 : npdf(pr.mu, pr.mu, pr.sig);
const gMax = Math.max(poMax, lMax, prMax) * 1.18;
ctx.fillStyle=cv('--paper'); ctx.fillRect(0,0,W,H);
// x-grid
ctx.strokeStyle=cv('--grid'); ctx.lineWidth=1;
for(let x=-4; x<=16; x+=2){
ctx.beginPath(); ctx.moveTo(xc(x),pT); ctx.lineTo(xc(x),pT+ph); ctx.stroke();
}
function curve(mu, sig, color, dash, lw, fill){
if(sig>60) return;
const pts=[];
for(let i=0;i<=400;i++){
pts.push({
x: xc(xMin+(xMax-xMin)*i/400),
y: yc(npdf(xMin+(xMax-xMin)*i/400, mu, sig), gMax)
});
}
if(fill){
ctx.beginPath();
ctx.moveTo(pts[0].x, yc(0,gMax));
pts.forEach(p=>ctx.lineTo(p.x,p.y));
ctx.lineTo(pts[400].x, yc(0,gMax));
ctx.closePath();
ctx.fillStyle=color+'30'; ctx.fill();
}
ctx.beginPath();
pts.forEach((p,i)=>i===0?ctx.moveTo(p.x,p.y):ctx.lineTo(p.x,p.y));
ctx.strokeStyle=color; ctx.lineWidth=lw;
ctx.setLineDash(dash); ctx.stroke(); ctx.setLineDash([]);
}
// flat prior: horizontal dash
if(pr.sig>60){
const fy = yc(gMax*0.04, gMax);
ctx.beginPath(); ctx.moveTo(pL,fy); ctx.lineTo(pL+pw,fy);
ctx.strokeStyle=cv('--prior-color'); ctx.lineWidth=2; ctx.setLineDash([7,5]); ctx.stroke(); ctx.setLineDash([]);
ctx.fillStyle=cv('--prior-color'); ctx.textAlign='left';
ctx.font=`400 12px 'DM Mono',monospace`;
ctx.fillText('Prior ≈ gleichverteilt', pL+10, fy-8);
} else {
curve(pr.mu, pr.sig, cv('--prior-color'), [7,5], 2, false);
}
// likelihood
curve(lMu, lSig, cv('--a5'), [3,3], 2, false);
// posterior (filled)
curve(po.mu, po.sig, cv('--a2'), [], 2.5, true);
// x-axis
ctx.strokeStyle=cv('--border'); ctx.lineWidth=1;
ctx.beginPath(); ctx.moveTo(pL,pT+ph); ctx.lineTo(pL+pw,pT+ph); ctx.stroke();
ctx.fillStyle=cv('--ink2');
ctx.font=`400 12px 'DM Mono',monospace`;
ctx.textAlign='center';
for(let x=-4; x<=16; x+=2){
const cx=xc(x);
ctx.beginPath(); ctx.moveTo(cx,pT+ph); ctx.lineTo(cx,pT+ph+5);
ctx.strokeStyle=cv('--border'); ctx.lineWidth=1; ctx.stroke();
ctx.fillText(x, cx, pT+ph+18);
}
ctx.fillStyle=cv('--ink2');
ctx.fillText('β (BDI-Punkte)', pL+pw/2, H-3);
// posterior annotation
const pmx = xc(po.mu);
const pmy = yc(npdf(po.mu,po.mu,po.sig),gMax) - 14;
ctx.fillStyle=cv('--a2');
ctx.font=`500 13px 'DM Mono',monospace`;
ctx.textAlign='center';
ctx.fillText('μ = '+po.mu.toFixed(2)+', σ = '+po.sig.toFixed(2),
pmx, Math.max(pT+10, pmy));
// legend (on canvas)
const items=[
{col:cv('--prior-color'), dash:[7,5], lw:2, label:'Prior'},
{col:cv('--a5'), dash:[3,3], lw:2, label:'Likelihood (konstant)'},
{col:cv('--a2'), dash:[], lw:2.5, label:'Posterior'},
];
let ly = pT+10;
items.forEach(it=>{
ctx.beginPath(); ctx.moveTo(W-170,ly); ctx.lineTo(W-142,ly);
ctx.strokeStyle=it.col; ctx.lineWidth=it.lw;
ctx.setLineDash(it.dash); ctx.stroke(); ctx.setLineDash([]);
ctx.fillStyle=it.col; ctx.textAlign='left';
ctx.font=`400 12px 'DM Mono',monospace`;
ctx.fillText(it.label, W-136, ly+4);
ly+=20;
});
}
function updateCRI(){
const pr = priorForMode();
const po = postParams(pr.mu, pr.sig);
const z = 1.96;
const lo = po.mu - z*po.sig;
const hi = po.mu + z*po.sig;
const w = hi-lo;
const refW = 8.24;
const pct = Math.round((1-w/refW)*100);
let lbl = 'Bayes — uninformativer Prior';
if(A2.mode==='informed') lbl = 'Bayes — informativer Prior (10 Studien)';
if(A2.mode==='custom') lbl = 'Bayes — eigener Prior';
document.getElementById('criLbl').textContent = lbl;
document.getElementById('criNums').textContent = '['+lo.toFixed(2)+', '+hi.toFixed(2)+']';
const wLabel = w.toFixed(2)+' Punkte'+(pct>5?' ↓ '+pct+'% schmäler':'');
document.getElementById('criW').innerHTML =
'Breite: '+wLabel.replace('↓','<b style="color:var(--a3)">↓')+(pct>5?'</b>':'');
document.getElementById('bInf').style.width = Math.min(100, Math.max(3, w/refW*100))+'%';
}
// ── HELP TOGGLE ───────────────────────────────────────────────
function toggleHelp(n){
const panel = document.getElementById('help'+n);
const btn = document.getElementById('h'+n+'btn');
const open = panel.classList.toggle('open');
btn.classList.toggle('open', open);
btn.textContent = open ? '✕ Hilfe ▾' : '? Hilfe ▸';
}
// ── INIT ──────────────────────────────────────────────────────
window.addEventListener('load', ()=>{
drawA1();
initA1Drag();
fillQ2Q3();
drawA2();
updateCRI();
});
window.addEventListener('resize', ()=>{ drawA1(); drawA2(); });
</script>
</body>
</html>