# /// script # requires-python = ">=3.12" # dependencies = ["marimo>=0.25.1", "numpy", "matplotlib"] # /// import marimo __generated_with = "0.25.1" app = marimo.App(width="medium") @app.cell(hide_code=True) def _(mo): mo.md( r""" # Science that runs *Why we are building ScienceHub. This page is a notebook: the numbers and the chart below are computed while you read.* ## Science is computation now In 1665 the first scientific journals turned letters between scholars into a public record. In 1991 arXiv put that record online, free and within a day. Both carried the same thing: a description of work. The work itself has changed. A climate projection, a protein structure, a gravitational-wave detection, a clinical trial's statistics: each is a computation, and the paper describes it from the outside. The code that produced the figure is usually somewhere else, if it is anywhere. And the cost of writing that code is falling fast. AI systems now write much of the code a researcher needs, so a biologist, a historian, or a physician can turn an idea into a working analysis in an afternoon. Soon most new science will be done as computation, by people who never trained as programmers. """ ) return @app.cell def _(): import marimo as mo import numpy as np import matplotlib.pyplot as plt return mo, np, plt @app.cell(hide_code=True) def _(mo): mo.md( r""" ## Most published computations do not run Code that exists is not code that works. In 2019 Pimentel and colleagues collected more than a million Jupyter notebooks from GitHub and ran the ones whose dependencies they could reconstruct. About a quarter finished without an error. About 4 percent reproduced the results their authors had saved. """ ) return @app.cell def _(plt): stages = ["ran without\nan error", "gave the\nsame results"] share = [24.1, 4.0] fig, ax = plt.subplots(figsize=(6, 2.4)) ax.barh(stages[::-1], share[::-1], color=["#9a6700", "#0969da"]) for _y, _v in enumerate(share[::-1]): ax.text(_v + 1, _y, f"{_v:.0f} %", va="center") ax.set_xlim(0, 100) ax.set_xlabel("share of executed notebooks (Pimentel et al. 2019)") for _side in ("top", "right"): ax.spines[_side].set_visible(False) fig.tight_layout() fig return @app.cell(hide_code=True) def _(mo): mo.md( r""" Hidden state is a large part of the reason. A classic notebook remembers whatever ran last, in whatever order it ran, and saves outputs that the code on the page may no longer produce. A marimo notebook does not: it knows which cell reads which variable and reruns everything that depends on a change. Move the slider and watch. """ ) return @app.cell def _(mo): trials = mo.ui.slider(10, 5000, step=10, value=200, label="Coin flips") trials return (trials,) @app.cell def _(mo, np, trials): flips = np.random.default_rng(1665).integers(0, 2, trials.value) heads = flips.mean() mo.md( f""" {trials.value:,} flips, **{heads:.1%} heads**. The interval {heads - 1.96 * np.sqrt(heads * (1 - heads) / trials.value):.1%} to {heads + 1.96 * np.sqrt(heads * (1 - heads) / trials.value):.1%} covers the true 50% about 95 times in 100. This sentence was recomputed when you moved the slider, and so would every figure that depends on it. """ ) return @app.cell(hide_code=True) def _(mo): mo.md( r""" ## What we believe **A result is the computation that produced it.** Publishing the description without the computation leaves out the part that can be checked. We publish both together, as one file. **Reading is free and needs nothing.** A public notebook runs in the reader's browser, with no account, no installation, and no cost to anyone. A student with a phone can rerun the calculation behind a published figure. **Your work is a plain Python file.** It diffs, imports, and runs anywhere marimo runs. You can take it with you. **Every version is kept and can be cited.** The notebook a paper cites is the notebook a reader gets, years later. Forks link back, so credit follows the work. **We do not sell attention.** No advertising, no paid ranking. We charge for compute when a browser is not enough, at a price shown before you use it. ## What comes after the paper Papers will not disappear; neither did letters. But the record of science is becoming something you can run, change, and build on. The place where that record lives should be public, permanent, and owned by the people who make it. That is what we are building. Fork this notebook and write your own answer. Or publish the computation behind your last paper, so that the next person can start where you stopped. """ ) return @app.cell(hide_code=True) def _(mo): mo.md( r""" --- **References.** J. F. Pimentel, L. Murta, V. Braganholo, J. Freire, "A Large-scale Study about Quality and Reproducibility of Jupyter Notebooks", MSR 2019. """ ) return if __name__ == "__main__": app.run()