Research breakthrough possible @S-Logix pro@slogix.in

Office Address

Social List

How to Use Statistical Functions from Python Numpy Module?

Statistical Functions from Python Numpy Module

Condition for Statistical Functions from Python Numpy Module

  • Description: NumPy is a powerful numerical computing library in Python that provides a wide range of statistical functions to perform operations such as mean, median, standard deviation, variance, etc., on arrays of data.
Step-by-Step Process
  • np.mean(): Returns the mean (average) of the elements.
  • np.median(): Returns the median (middle value) of the elements.
  • np.std(): Returns the standard deviation, a measure of the spread of the dataset.
  • np.var(): Returns the variance, showing how spread out the numbers are.
  • np.min(): Returns the smallest value.
  • np.max(): Returns the largest value.
  • np.sum(): Returns the sum of all elements.
  • np.percentile(): Returns the nth percentile of the data.
Sample Code
  • print("Output for Statistical function:")
    import numpy as np
    data = np.array([12, 15, 10, 20, 25, 30, 35, 40, 50])
    # Mean
    mean_value = np.mean(data)
    print(f"Mean: {mean_value}")
    print()
    # Median
    median_value = np.median(data)
    print(f"Median: {median_value}")
    print()
    # Standard Deviation
    std_deviation = np.std(data)
    print(f"Standard Deviation: {std_deviation}")
    print()
    # Variance
    variance = np.var(data)
    print(f"Variance: {variance}")
    print()
    # Minimum and Maximum
    min_value = np.min(data)
    max_value = np.max(data)
    print(f"Min: {min_value}")
    print(f"Max: {max_value}")
Screenshots
  • Statistical Functions from Python Numpy Module1