Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Descriptive statistics summarize, describe, and reveal properties of numerical datasets. In data science, feature engineering, and statistical modeling, calculating aggregates—such as totals, averages, standard deviations, and variances—is a fundamental first step.
NumPy provides highly optimized aggregation functions implemented in C, equipped with options for numerical stability and degree-of-freedom adjustments.
ddof ParameterA critical statistical distinction often missed by beginners is Degrees of Freedom:
$$\sigma^2_{\text{pop}} = \frac{1}{N} \sum_{i=1}^N (x_i - \mu)^2 \qquad s^2_{\text{sample}} = \frac{1}{N - 1} \sum_{i=1}^N (x_i - \bar{x})^2$$
np.var() and np.std() set ddof=0 (Population variance, dividing by $N$)..var() and .std() set ddof=1 (Sample variance, dividing by $N - 1$, Bessel's correction).To match unbiased sample statistics in academic research or Pandas:
Output:
cumsum() and cumprod()In time-series analysis and financial quantitative modeling, running totals and compound returns are computed via cumulative functions:
nanmean, nansum, etc.If an array contains even a single np.nan (Not a Number), standard aggregation functions return nan by default:
NumPy includes a dedicated family of NaN-safe functions that automatically ignore missing values during computation:
ddof) parameter in np.std() and np.var()?[5.0, 15.0, np.nan], what does np.mean(arr) evaluate to?data = np.array([10, 20, 30]), what is the result of np.cumprod(data)?x in NumPy?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Universal Functions (ufuncs), Trigonometry & Logarithms | Directional Aggregations with the axis Parameter |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.