Interactive probability explorer: Altair vs GenStudio

This is a throwaway comparison notebook. The master article is unchanged. Both charts use the same bias and sample-size sliders, the same probabilities, and the same article palette. Neither uses pandas. They can be exported as standalone interactive HTML.

Install the extra libraries once in your environment (uv add altair genstudio).

import sys
from pathlib import Path

sys.path.insert(0, str(Path.cwd()))
from altair_explorer import build_chart as build_altair_chart
from genstudio_explorer import build_chart as build_genstudio_chart
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 5
      1 import sys
      2 from pathlib import Path
      3 
      4 sys.path.insert(0, str(Path.cwd()))
----> 5 from altair_explorer import build_chart as build_altair_chart
      6 from genstudio_explorer import build_chart as build_genstudio_chart

ModuleNotFoundError: No module named 'altair_explorer'

Altair (Vega-Lite)

The sliders run Vega expressions against a precomputed set of binomial coefficients, and the display updates without a Python kernel.

altair_chart = build_altair_chart()
altair_chart
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 altair_chart = build_altair_chart()
      2 altair_chart

NameError: name 'build_altair_chart' is not defined

Hide code cell source

altair_chart.save("altair_probability_explorer.html")
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[3], line 1
----> 1 altair_chart.save("altair_probability_explorer.html")

NameError: name 'altair_chart' is not defined

GenStudio (Observable Plot)

GenStudio uses reactive state. Moving either slider recomputes the two distributions in the browser.

genstudio_chart = build_genstudio_chart()
genstudio_chart.display_as("html")
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[4], line 1
----> 1 genstudio_chart = build_genstudio_chart()
      2 genstudio_chart.display_as("html")

NameError: name 'build_genstudio_chart' is not defined

Hide code cell source

genstudio_chart.save_html("genstudio_probability_explorer.html")
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 genstudio_chart.save_html("genstudio_probability_explorer.html")

NameError: name 'genstudio_chart' is not defined

What to compare

Styling and typography; slider responsiveness; vertical spacing (especially whether the next Markdown cell is obscured); exported standalone HTML; and the readability of the Python source. Try p=0.8, N=6, p=0.5, N=20, and p=0.6, N=30.