Recap: Battery Life
Part of the Statistics for ML section of Coddy's Machine Learning journey. Lesson 12 of 64.
Challenge
EasyDraw the chart this chapter opened with. hours holds 300 laptop battery lives. Using their mean and std (np.std):
- Print the shortest life and how many std below the mean it lies (2 decimals).
- Print the percent within 2 std (1 decimal).
- Draw a density histogram (
bins=20), the fitted curve (100 points) and a red dot under the worst battery, at height 0. - Title
Battery Life, axesHoursandDensity.
For another test of 250 laptops:
Worst battery: 9.7 hours, 2.94 std below the mean
Within 2 std: 95.2% (the rule says about 95%)and the chart:
Try it yourself
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
# Don't change the lines below
rng = np.random.default_rng(44)
hours = np.round(rng.normal(14, 1.5, size=300), 1)
# Write your code below
All lessons in Statistics for ML
1Center and Spread
Mean and MedianPercentiles and QuartilesVariance and StdSample or Population?The Most Common ValueRecap: Delivery Times4Samples and Populations
Population and SampleSample Means VaryThe Sampling DistributionBigger Samples, Less NoiseRecap: Polling a Town2Distributions
Density HistogramsShapes of DataThe Normal CurveThe 68-95-99.7 RuleZ-ScoresRecap: Battery Life3Probability by Simulation
Probability as FrequencyThe Law of Large NumbersSums of DiceExpected ValueConditional ProbabilityRecap: Dice Stall Odds6Relationships
Reading Scatter PlotsCorrelationCorrelation MatrixCorrelation HeatmapsCorrelation Is Not CauseRecap: Ice Cream and SunPractice on your own: Online Python compiler