{ "cells": [ { "cell_type": "markdown", "id": "cd304e32-1231-4b6a-9be9-3e160c9981aa", "metadata": {}, "source": [ "# Title of my notebook\n", "\n", "Some text.\n", "\n", "![Photo of Galilei's manuscript](https://upload.wikimedia.org/wikipedia/commons/b/b3/Galileo_Galilei_%281564_-_1642%29_-_Serenissimo_Principe_-_manuscript_with_observations_of_Jupiter_and_four_of_its_moons%2C_1610.png)\n", "\n", "$E = mc^2$" ] }, { "cell_type": "code", "execution_count": 1, "id": "8e336c21-ec93-4d81-adc3-c014521900ed", "metadata": {}, "outputs": [], "source": [ "def arithmetic_mean(sequence):\n", " s = 0.0\n", " for element in sequence:\n", " s += element\n", " n = len(sequence)\n", " return s / n" ] }, { "cell_type": "code", "execution_count": 2, "id": "f0574887-56e6-4388-a730-9efc6b50bb23", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3.0" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "arithmetic_mean([1, 2, 3, 4, 5])" ] }, { "cell_type": "code", "execution_count": 3, "id": "7154620e-1286-4f90-a484-8baaf2fe6b7d", "metadata": {}, "outputs": [], "source": [ "# this is here for google colab to update altair\n", "import altair as alt\n", "if not alt.__version__.startswith(\"5\"):\n", " %pip install altair==5.3.0" ] }, { "cell_type": "code", "execution_count": 4, "id": "fd726642-41ae-434c-80c7-2d250258807b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# this example is from https://altair-viz.github.io/gallery/layered_histogram.html\n", "\n", "import pandas as pd\n", "import altair as alt\n", "import numpy as np\n", "np.random.seed(42)\n", "\n", "# Generating Data\n", "source = pd.DataFrame({\n", " 'Trial A': np.random.normal(0, 0.8, 1000),\n", " 'Trial B': np.random.normal(-2, 1, 1000),\n", " 'Trial C': np.random.normal(3, 2, 1000)\n", "})\n", "\n", "alt.Chart(source).transform_fold(\n", " ['Trial A', 'Trial B', 'Trial C'],\n", " as_=['Experiment', 'Measurement']\n", ").mark_bar(\n", " opacity=0.3,\n", " binSpacing=0\n", ").encode(\n", " alt.X('Measurement:Q').bin(maxbins=100),\n", " alt.Y('count()').stack(None),\n", " alt.Color('Experiment:N')\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }