concept curve in category data

This is an excerpt from Manning's book Data Science Bookcamp: Five Python Projects.
Within the plot, Curve A resembles a short yet muscular bodybuilder; the curve’s maximum height is not that impressive even though its horizontal bulk covers a noticeable amount of area. Meanwhile, Curve B could be compared to a taller and thinner individual; the girth doesn’t cover that much area even though its peak towers over highest point within Curve A. Since Curve A is wider, its area over more extreme head-frequency intervals is larger. Hence, observed recordings of such frequencies are more likely to occur when the coin-flip count is 10 and not 20. Meanwhile, the thinner more vertical Curve B covers more area around the central 0.5 frequency.
What will happen when more than 20 coins are flipped? How will the increased flip-count influence our frequency distribution? According to probability theory, each additional coin-flip will the cause the frequency curve to grow even taller and thinner. The curve will transform like a stretched rubber band that’s being pulled vertically upward. It will lose thickness in exchange for vertical length. As the total number of coin flips extends into the millions and billions, the curve will completely lose its girth; becoming just single, very long vertical peak whose center lies at a frequency of 0.5. Beyond that frequency, the non-existent area beneath vertical line will approach zero. It follows that the area beneath the peak will approach 1.0, because our total area must always equal 1.0. The area of 1.0 corresponds to a probability of 1.0. Thus, as the number of coin flips approaches infinity, the frequency of heads will come to equal the actual probability of heads with absolute certainty.
The Normal distribution is a bell-shaped curve that we introduced in Section Three. The curve arises naturally from random data sampling, due to the Central Limit Theorem. Previously, we noted how according to that theorem, repeatedly sampled frequencies will take the shape of a Normal curve. Furthermore, the theorem predicts a narrowing of that curve as the size of each frequency-sample goes up. In other words, the distribution’s standard deviation should decrease as the sampling size grows larger.
The plotted curve fits nicely over the histogram. The curve’s peak sits at an x-axis position of 0.5, and rises to a y-axis position of approximately 80. As a reminder, the peak’s x and y coordinates are a direct function of
fitted_meanandfitted_std. In order to emphasize this import relationship, lets do a simple exercise. We’ll shift the peak 0.01 units to the right, while also doubling the peak’s height. How do we execute the shift? Well, the peak’s axis is equal to the mean, so we’ll adjust the input mean tofitted_mean + 0.01. Also, the peak’s height is inversely proportional to the standard deviation. Therefore, inputtingfitted_std / 2should double the height of the peak.Listing 6.8. Manipulating a Normal curve’s peak coordinates
adjusted_likelihoods = stats.norm.pdf(bin_edges, fitted_mean + 0.01, fitted_std / 2) plt.plot(bin_edges, adjusted_likelihoods, color='k', linestyle='--') plt.hist(sample_means, bins='auto', alpha=0.2, color='r', density=True) plt.xlabel('Sample Mean') plt.ylabel('Relative Likelihood') plt.show()Figure 6.3. A modified Normal curve whose center is .01 units to the right of the histogram. The peak of the curve is twice the height of the histogram’s peak. These modifications were achieved by manipulating the histogram’s mean and standard deviation.
![]()