DeveloperBreeze

Calculate Mean and Standard Deviation of NumPy Array

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)

Related Posts

More content you might like

Tutorial
python

كيف تبدأ رحلتك مع الذكاء الاصطناعي: دليل عملي للمبتدئين

لنستخدم خوارزمية الانحدار الخطي:

from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression

# تقسيم البيانات إلى تدريب واختبار
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# إنشاء وتدريب النموذج
model = LinearRegression()
model.fit(X_train, y_train)

# اختبار النموذج
accuracy = model.score(X_test, y_test)
print(f"دقة النموذج: {accuracy:.2f}")

Dec 12, 2024
Read More
Code
javascript

Find Maximum Number in Array Using Math.max

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Remove Duplicates from Array Using Set

No preview available for this content.

Jan 26, 2024
Read More
Code
csharp

Calculate Sum of Numbers in Array

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!