Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Views: 2115
Image: ubuntu2004
Kernel: Python 3 (system-wide)

Exercise 2.1: Firefly flashes

The data in the file FireflyFlash.csv are flash durations in milliseconds of a sample of male fireflies of the species Photinus ignitus.

  1. Read the data into a pandas DataFrame and print it.

  2. Create a labelled histogram of the flash durations.

%matplotlib inline import pandas as pd import matplotlib.pyplot as plt fireflies = pd.read_csv('FireflyFlash.csv') fireflies
fireflies['flash'].plot.hist() plt.xlabel('Flash duration (milliseconds)') plt.ylabel('Number of fireflies') plt.title('Histogram of flash duration of 35 male fireflies');

Exercise 2.2: Swimming in syrup

Can a human swim faster in water or in syrup? It is unknown whether the increase in the friction of the body moving through the syrup (slowing the swimmer down) is compensated by the increased power of each stroke (speeding the swimmer up). Finally, an experiment was done by Gettelfinger and Cussler (2004) in which they filled one pool with water mixed with syrup (gua rgum) and another pool with normal water. They had 18 swimmers swim laps in both pools in random order. The data (in the file SyrupSwimming.csv) are presented as the relative speed of each swimmer in syrup (speed in the syrup pool divided by his or her speed in the water pool). If the syrup has no effect on swimming speed, then relative swim speed should have a mean of 1.

  1. Read the data from the file SyrupSwimming.csv into a pandas DataFrame and print it.

  2. Create a labelled histogram of the relative speed of the swimmers.

  3. From looking at the histogram would you conclude that swimmers swim faster, slower, or at the same speed in syrup as in water?

rel_speed = pd.read_csv('SyrupSwimming.csv') rel_speed
rel_speed['relativeSpeedInSyrup'].plot.hist() plt.xlabel('Relative speed in syrup over water') plt.ylabel('Number of swimmers') plt.title('Histogram of relative speed of swimmers in syrup over water');

Six swimmers were slower in syrup than in water and 12 were faster. The might be evidence that swmimmers are faster but it is not very strong. A larger sample size is required to be more certain.