Challenge - 5 Problems
Descriptive Statistics Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateCalculate mean, median, and standard deviation
What is the output of the following MATLAB code calculating mean, median, and standard deviation of the vector
A?MATLAB
A = [2, 4, 6, 8, 10]; mean_val = mean(A); median_val = median(A); std_val = std(A); result = [mean_val, median_val, std_val];
Attempts:
2 left
💡 Hint
Recall that mean and median are measures of central tendency, and std is the spread.
✗ Incorrect
The mean and median of the vector [2,4,6,8,10] are both 6 because the data is symmetric. The standard deviation is approximately 3.1623.
❓ data_output
intermediateNumber of elements above mean
Given the vector
B = [1, 3, 5, 7, 9, 11], how many elements are strictly greater than the mean of B?MATLAB
B = [1, 3, 5, 7, 9, 11]; mean_B = mean(B); count_above_mean = sum(B > mean_B);
Attempts:
2 left
💡 Hint
Calculate the mean first, then count elements greater than it.
✗ Incorrect
The mean of B is 6. Elements greater than 6 are 7, 9, and 11, so count is 3.
🔧 Debug
advancedIdentify the error in standard deviation calculation
What error will the following MATLAB code produce?
MATLAB
C = [4, 8, 12, 16]; std_val = std(C, 1);
Attempts:
2 left
💡 Hint
Check MATLAB documentation for std function syntax.
✗ Incorrect
The second argument '1' tells MATLAB to compute the population standard deviation. This is valid syntax and produces no error.
🧠 Conceptual
advancedEffect of outliers on mean and median
Which statement correctly describes the effect of an extreme outlier on the mean and median of a dataset?
Attempts:
2 left
💡 Hint
Think about which measure is sensitive to extreme values.
✗ Incorrect
Mean is sensitive to extreme values because it averages all data points, while median depends on the middle value and is more robust.
🚀 Application
expertCalculate mean and std ignoring NaN values
Given the vector
D = [3, NaN, 7, 9, NaN, 5], which MATLAB code correctly calculates the mean and standard deviation ignoring NaN values?Attempts:
2 left
💡 Hint
Check how to exclude NaN values in MATLAB calculations.
✗ Incorrect
Option A manually filters out NaN values before calculating mean and std, which works in all MATLAB versions. Option A uses 'omitnan' flag, a feature introduced in later MATLAB releases.
