Published on January 26, 2024By DeveloperBreeze

Python Example: Calculating Mean and Standard Deviation

The following Python code demonstrates how to calculate the mean and standard deviation of an array using NumPy:

import numpy as np

# Create an array
arr = np.array([10, 20, 30, 40, 50])

# Calculate and print the mean
mean = np.mean(arr)
print('Mean:', mean)

# Calculate and print the standard deviation
std_dev = np.std(arr)
print('Standard Deviation:', std_dev)

Comments

Please log in to leave a comment.

Continue Reading:

Create and Save Random Color Grid as PNG Image

Published on January 26, 2024

python

Filtering and Selecting Elements in NumPy Array

Published on January 26, 2024

python

Reshape NumPy Array

Published on January 26, 2024

python

Create a NumPy 1D Array

Published on January 26, 2024

python

Calculate Sum of Numbers in Array

Published on January 26, 2024

csharp

Remove Duplicates from Array Using Set

Published on January 26, 2024

javascript

Find Maximum Number in Array Using Math.max

Published on January 26, 2024

javascript

Matrix Multiplication in Python using NumPy

Published on January 26, 2024

python