{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Computing things!\n", "\n", "
" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [] }, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "You may remember that we worked with a Numpy array:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "tags": [] }, "outputs": [], "source": [ "x = np.array(\n", " [\n", " 1828, 2131, 1851, 2030, 1930, 1660, 1721, 1740, 1752, 1863, 2141,\n", " 1701, 1661, 1712, 1749, 1642, 1882, 1821, 1800, 1692, 1680, 1671,\n", " 1683, 1833, 1800, 1930, 1910, 1821, 1840, 1787, 1683, 1809, 1951,\n", " 1892, 1731, 1751, 1802, 1912, 1781, 2091, 1852, 1792, 2061, 1683\n", " ],\n", " dtype=float\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Those numbers are actually from a data set from [Harvey and Orbidans, PLoS One, 2011](https://doi.org/10.1371/journal.pone.0025840) on the cross-sectional area of *C. elegans* eggs. \n", "\n", "Now we would like to compute the diameter of the egg from the cross-sectional area. Write a function that takes in an array of cross-sectional areas and returns an array of diameters. Recall that the diameter $d$ and cross-sectional area $A$ are related by $A = \\pi d^2/4$. There should be no `for` loops in your function! The call signature is\n", "\n", "```python\n", "xa_to_diameter(x)\n", "```\n", "\n", "Use your function to compute the diameters of the eggs." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] } ], "metadata": { "anaconda-cloud": {}, "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.13.5" } }, "nbformat": 4, "nbformat_minor": 4 }