我的 Std Dev 和 Variance 与他们显示的不同

问题描述

    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    
    

注意:所有答案必须是浮点数据类型。将您的答案四舍五入到 2 位数。

import numpy as np
from scipy import stats
import statistics as st

def stats_values(arr):
  
    #Write your code here
    
    print("{:.2f}".format(st.mean(a)))
    print("{:.2f}".format(st.median(a)))
    print("{:.2f}".format(st.stdev(a)))
    print("{:.2f}".format(st.variance(a)))
    print("{:.2f}".format(st.mode(a)))
    q3,q1 = np.percentile(a,[75,25])
    iqr=q3-q1
    print("{:.2f}".format(iqr))


n=int(input("enter no. of rows you want\n"))
a=[]
for i in range(n):
    p=float(input())
    a.append(p)

stats_values(a)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)