Write a function stats_values() that prints the statistics values of given array
Answers
Answer:
Input : arr - Numpy array #Output: Function must print the statistics of the array in the following order #1. Mean #2. Median #3. Standard Deviation #4. Variance #5. Mode #5. Inter-Quartile Range #Note: All the answers must be of Float datatype.Round your answers to 2 digits.
Answer:
The following function performs the desired task:
import numpy as np
def stat_values(x):
arr = np.array(x)
print(np.mean(arr))
print(np.median(arr))
print(np.var(arr))
print(np.std(arr))
x = [18,90,87,90,34,22,11,32]
stats_values(x)
Explanation:
There are four most important operations of statistics named as mean, median, variance, and standard deviation.
Let's see each of them one by one.
Mean: The mean is the average value of the given data. It is calculated by using the mean() method of the NumPy library.
Median: The median shows the middle of the data. It is more useful than the mean since the mean can vary widely over due to one value. It is calculated by using the median() method.
Variance: It is the average of the squared differences from the mean. We have a variance() method to figure out the variance.
Standard Deviation: It is a measure to show how spread out our data is. It is calculated with the std() method of Numpy.
#SPJ3