I’m trying to write a notebook for two purposes - to teach a little probability theory and to show how kids (middle school) should/could use Observable. I don’t love the viewof/generator stuff in this simple example, but I get the purpose. I’m wondering if folks can see a way to make the bulk flow of the notebook more readable, perhaps hiding more stuff down “at the bottom”?
Then I know I have lots of work to do on pretty pictures and graphs to show them convergence. Maybe I can even throw in some simple ML.
Not sure how much this helps, but here’s my take on the simulation:
The main difference is that I pinned the cells that perform the simulation so that I can explain how they work. I also refactored it so that the code for running a single simulation is independent of the animation/iteration. Then I used a generator at the end to show how the values converge.
1. It’s easier if you avoid mutable state… In mine, the cells rerun from scratch whenever something they reference changes, so I don’t have to remember to reset.
2. You can import checkbox from Jeremy’s inputs bazaar for a nice labeled checkbox:
3. Yes, you can define a view that waits for you to click a button. Here is an example: