Menu
×
×
   ❮   
PYTHON FOR DJANGO DJANGO FOR BEGINNERS DJANGO SPECIFICS PAYMENT INTEGRATION API BASICS NUMPY FOR ML Roadmap
     ❯   

MATHEMATICAL OPERATIONS IN NUMPY

Statistical Functions

×

Share this Topic

Share Via:

Thank you for sharing!


Statistical Computations in NumPy

NumPy provides a suite of powerful functions for performing statistical computations, which makes it a crucial tool in data analysis and machine learning. These functions help summarize and understand the characteristics of datasets quickly and efficiently.

Key Statistical Metrics

  • Mean (Average): The mean is the sum of all elements divided by the number of elements. It provides the central tendency of the data.
  • Median: The median is the middle value when the data is sorted. It is less sensitive to outliers than the mean, making it useful for skewed distributions.
  • Standard Deviation: Standard deviation measures the spread of data points from the mean. A higher standard deviation indicates greater variability in the data.
  • Variance: Variance is the square of the standard deviation. It gives a sense of the data's spread around the mean.
  • Minimum and Maximum Values: These values identify the smallest and largest numbers in the dataset, providing insights into the data range.
  • Index of Minimum and Maximum Values: These functions return the index positions of the smallest and largest values, which can be useful for locating extreme values in the dataset.

Example of Statistical Functions


import numpy as np

# Creating a dataset
data = np.array([10, 20, 30, 40, 50])

# Calculating key statistics
print("Mean (Average):", np.mean(data))         # 30.0
print("Median (Middle value):", np.median(data)) # 30.0
print("Standard Deviation:", np.std(data))      # Measures data spread
print("Variance:", np.var(data))                # Square of standard deviation
print("Minimum value:", np.min(data))           # Smallest value
print("Maximum value:", np.max(data))           # Largest value
print("Index of Minimum Value:", np.argmin(data)) # Index of smallest value
print("Index of Maximum Value:", np.argmax(data)) # Index of largest value

Applications in Machine Learning:

  • Used to normalize data for machine learning models, ensuring that each feature contributes equally to the model.
  • Helps in data preprocessing and feature engineering by providing insights into data distribution and potential transformations.
  • Essential for exploratory data analysis (EDA), where statistical metrics guide data understanding and feature selection.

Statistical computations in NumPy are not only helpful for descriptive analysis but also for preparing data for machine learning algorithms, making them a key aspect of the data science workflow.


Django-tutorial.dev is dedicated to providing beginner-friendly tutorials on Django development. Examples are simplified to enhance readability and ease of learning. Tutorials, references, and examples are continuously reviewed to ensure accuracy, but we cannot guarantee complete correctness of all content. By using Django-tutorial.dev, you agree to have read and accepted our terms of use , cookie policy and privacy policy.

© 2025 Django-tutorial.dev .All Rights Reserved.
Django-tutorial.dev is styled using Bootstrap 5.
And W3.CSS.