57  Computing things!

Open in Google Colab | Download notebook


import numpy as np

You may remember that we worked with a Numpy array:

x = np.array(
    [
        1828, 2131, 1851, 2030, 1930, 1660, 1721, 1740, 1752, 1863, 2141,
        1701, 1661, 1712, 1749, 1642, 1882, 1821, 1800, 1692, 1680, 1671,
        1683, 1833, 1800, 1930, 1910, 1821, 1840, 1787, 1683, 1809, 1951,
        1892, 1731, 1751, 1802, 1912, 1781, 2091, 1852, 1792, 2061, 1683
    ],
    dtype=float
)

Those numbers are actually from a data set from Harvey and Orbidans, PLoS One, 2011 on the cross-sectional area of C. elegans eggs.

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

xa_to_diameter(x)

Use your function to compute the diameters of the eggs.