import%20marimo%0A%0A__generated_with%20%3D%20%220.14.10%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20plotly.express%20as%20px%0A%20%20%20%20import%20pandas%20as%20pd%0A%20%20%20%20return%20mo%2C%20np%2C%20pd%2C%20px%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20Example%201.1%20Suppose%20I%20drop%20a%20rock%20off%20a%20cliff%20of%20height%20h.%20As%20it%20falls.%20I%20snap%20a%20million%20photographs%2C%20at%20random%20intervals.%20On%20each%20picture%20I%20measure%20the%20divtage%20the%20rock%20has%20fallen.%20%0A%0A%20%20%20%20Question%3A%20What%20is%20the%20arerage%20of%20all%20these%20divances%3F%20That%20is%20to%20say%2C%20what%20is%20the%20time%20average%20of%20the%20distance%20traveled!%20%0A%0A%20%20%20%20Solution%3A%20The%20rock%20starts%20out%20at%20rest%2C%20and%20picks%20up%20speed%20as%20it%20falls%3B%20it%20spends%20more%20time%20near%20the%20top%2C%20so%20the%20average%20distance%20must%20be%20less%20than%20%24h%2F2%24.%20%20Ignoring%20air%20resistance%2C%20the%20distance%20%0A%20%20%20%20%20at%20time%20%0A%20%20%20%20%20is%20%24x(t)%3D%5Cfrac%7B1%7D%7B2%7D%20g%20t%5E2%24.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20We%20need%20to%20calculate%20the%20time%20it%20takes%20for%20the%20rock%20to%20travel%20a%20distance%20h.%20%20That%20is%20what%20is%20it%20if%20x(t)%20%3D%20h.%20%20We%20find%20the%20inverse%20equation%20%24t_%7Btotal%7D%20%3D%20%5Csqrt%7B%5Cfrac%7B2%20h%7D%7Bg%7D%7D%24.%20%20Now%20it%20may%20be%20easier%20to%20express%20everything%20in%20unitless%20variables%20so%20expressing%20time%20as%20a%20fraction%20of%20total%20time%20and%20distance%20as%20a%20fraction%20of%20%24h%24%20so%20that%20yields%20the%20following%20relationship.%0A%0A%20%20%20%20%24%24s%20%3D%20%5Cfrac%7Bt%7D%7Bt_%7Btotal%7D%7D%20%3D%20%5Cfrac%7B%20%5Csqrt%7B(2x)%2Fg%7D%7D%7B%5Csqrt%7B(2h)%2Fg%7D%7D%20%5Ctextrm%7B%20where%20%7D%200%5Cleq%20s%20%5Cleq%201%24%24%0A%0A%20%20%20%20Now%20if%20we%20also%20express%20x%20as%20a%20percentage%20of%20h%20with%20another%20variable%20u%20such%20that%20%240%20%5Cleq%20u%20%5Cleq%201%24%20and%20%24x%20%3D%20u%20h%24%20then%20the%20above%20becomes%3A%0A%0A%20%20%20%20%24%24s%20%3D%20%5Cfrac%7Bt%7D%7Bt_%7Btotal%7D%7D%20%3D%20%5Cfrac%7B%5Csqrt%7B(2uh)%2Fg%7D%7D%7B%5Csqrt%7B(2h)%2Fg%7D%7D%20%3D%20%5Csqrt%7Bu%7D%20%5Ctextrm%7B%20where%20%7D%200%5Cleq%20s%20%5Cleq%201%20%5Ctextrm%7B%20and%20%7D%200%20%5Cleq%20u%20%5Cleq%201%24%24%0A%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(np%2C%20pd%2C%20px)%3A%0A%20%20%20%20rng%20%3D%20np.random.default_rng()%0A%20%20%20%20data%20%3D%20rng.random(size%3D100000)%0A%0A%20%20%20%20%23%20If%20we%20want%20to%20sample%20the%20corresponding%20distances%20that%20it%20has%20travelled%20then%20we%20need%20the%20%0A%20%20%20%20%23%20inverse%20relation%20of%20u%20%3D%20s%5E2%0A%20%20%20%20values%20%3D%20%7B'distance'%3A%20data*data%7D%0A%0A%20%20%20%20df%20%3D%20%20pd.DataFrame(values)%0A%0A%20%20%20%20%23%20Create%20the%20histogram%0A%20%20%20%20fig%20%3D%20px.histogram(df%2C%20x%3D%22distance%22%2C%20title%3D%22Distribution%20of%20Rock%20Travel%20Distances%22)%0A%20%20%20%20fig.show()%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
0c9e8346bee21b6633d7705902d79e86c577d66a1624d736c81efc9d84dedacb