Aan de slagGa gratis aan de slag

Calculating relative errors

The size of the sample you take affects how accurately the point estimates reflect the corresponding population parameter. For example, when you calculate a sample mean, you want it to be close to the population mean. However, if your sample is too small, this might not be the case.

The most common metric for assessing accuracy is relative error. This is the absolute difference between the population parameter and the point estimate, all divided by the population parameter. It is sometimes expressed as a percentage.

attrition_pop and mean_attrition_pop (the mean of the Attrition column of attrition_pop) are available; pandas is loaded as pd.

Deze oefening maakt deel uit van de cursus

Sampling in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Generate a simple random sample of 50 rows, with seed 2022
attrition_srs50 = ____

# Calculate the mean employee attrition in the sample
mean_attrition_srs50 = ____

# Calculate the relative error percentage
rel_error_pct50 = ____

# Print rel_error_pct50
print(rel_error_pct50)
Code bewerken en uitvoeren