Why random generation matters
📖 Scenario: Imagine you are a data scientist working with a large dataset of customer ages. You want to understand how random sampling can help you estimate the average age without looking at the entire dataset.
🎯 Goal: You will create a dataset of ages, set a sample size, randomly select a sample, and then calculate the average age of that sample to see how it compares to the whole dataset.
📋 What You'll Learn
Create a numpy array called
ages with these exact values: 22, 25, 47, 35, 46, 52, 23, 43, 36, 44Create a variable called
sample_size and set it to 4Use
numpy.random.choice to randomly select sample_size ages from ages and store in sampleCalculate the average of
sample and store it in sample_averagePrint the
sample array and the sample_average value💡 Why This Matters
🌍 Real World
Random sampling is used in surveys, polls, and experiments to estimate results without checking every individual.
💼 Career
Data scientists use random sampling to analyze big data efficiently and make predictions or decisions based on samples.
Progress0 / 4 steps