Skip to content

probability: add a Studio explainer view for Bayes' theorem - #155

Open
bjornts wants to merge 2 commits into
marimo-team:mainfrom
bjornts:bayes-studio-explainer
Open

bjornts wants to merge 2 commits into
marimo-team:mainfrom
bjornts:bayes-studio-explainer

Conversation

@bjornts

@bjornts bjornts commented Nov 16, 2026 •

Copy link
Copy Markdown

📝 Summary

Akshay invited CS 146S students to build marimo studio views of learn notebooks. This adds one for lesson 8, Bayes' theorem, in probability/studio/08_bayes_theorem/explainer/.

The view shows what the lesson describes: evidence shrinks the set of outcomes. Each worked example gets a before/after area model, and the interactive square can collapse to only the outcomes where E happened, so the prior visibly becomes the posterior. The notebook's area walkthrough sits beside it and updates with the sliders. All numbers come from the notebook.

Notebook changes:

  • Named the Markdown cells the view places.
  • Moved the area walkthrough into its own area_walkthrough cell. The notebook renders the same.
  • Added a hidden area_inputs cell, because a projected p_h.value doesn't update when the slider moves.
  • The sliders open on the student example and show their values.
  • Fixed times → \times in the medical example.
  • The header adds marimo-studio==0.4.1 and [tool.marimo-studio].

Tested with marimo run on desktop and phone. marimo-studio validate and the repo checks pass.

No learn notebook has a view yet, so this uses Studio's default <course>/studio/<notebook>/<view>/ layout. Happy to move it.

📋 Checklist

  • I have included package dependencies in the notebook file using --sandbox
  • If adding a course, include a README.md (not applicable)
  • Keep language direct and simple.

Add probability/studio/08_bayes_theorem/explainer, a marimo studio view of
lesson 8 built around how evidence shrinks the set of outcomes: before/after
area models for the worked examples, an "only where E happened" switch on the
interactive model, and the notebook's live walkthrough beside it.

In the notebook, name the Markdown cells the view places, move the area
walkthrough into its own cell, add a hidden area_inputs cell for the view,
open the sliders on the student example, and fix the \times typo in the
medical example.
Stack the area walkthrough under the parameters with mo.vstack instead of
interpolating it into the indented Markdown, which rendered as a code block.

In the view, only make the workbench sticky when it fits the viewport,
follow hashchange, keep the "prior" label inside one region, update the
image's accessible name with the mode, and announce the "E never happens"
note.
@akshayka

Copy link
Copy Markdown
Contributor

@bjornts Thanks for the PR! Can you include a short video that showcases the view you added?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants