#!/usr/bin/env python # coding: utf-8 # # Title of my notebook # # Some text. # # ![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) # # $E = mc^2$ # In[1]: def arithmetic_mean(sequence): s = 0.0 for element in sequence: s += element n = len(sequence) return s / n # In[2]: arithmetic_mean([1, 2, 3, 4, 5]) # In[3]: # this is here for google colab to update altair import altair as alt if not alt.__version__.startswith("5"): get_ipython().run_line_magic('pip', 'install altair==5.3.0') # In[4]: # this example is from https://altair-viz.github.io/gallery/layered_histogram.html import pandas as pd import altair as alt import numpy as np np.random.seed(42) # Generating Data source = pd.DataFrame({ 'Trial A': np.random.normal(0, 0.8, 1000), 'Trial B': np.random.normal(-2, 1, 1000), 'Trial C': np.random.normal(3, 2, 1000) }) alt.Chart(source).transform_fold( ['Trial A', 'Trial B', 'Trial C'], as_=['Experiment', 'Measurement'] ).mark_bar( opacity=0.3, binSpacing=0 ).encode( alt.X('Measurement:Q').bin(maxbins=100), alt.Y('count()').stack(None), alt.Color('Experiment:N') )