python二分法查找程序_Python程序查找标准偏差

python二分法查找程序

While dealing with a large data, how many samples do we need to look at before we can have justified confidence in our answer? This depends on the variance of the dataset.

在处理大量数据时,我们需要先查看多少样本,才能对我们的答案有充分的把握? 这取决于数据集的方差。

Variance tells us about the divergence and the inconsistency of the sample. The standard deviation of a collection of values is the square root of the variance. While it contains the same information as the variance. But Standard deviation is quite more referred. Why? Look at the below statement:

方差告诉我们样本的差异和不一致。 值集合的标准偏差是方差的平方根。 虽然它包含与方差相同的信息。 但是标准偏差要多得多。 为什么? 看下面的语句:

The mean income of the population is 846000 with a standard deviation of 4000.
The mean income of the population is 846000 with a variance of 16000000.

人口的平均收入是846000, 标准差是4000。
人口的平均收入是846000,方差16000000。

Now see which statement is more favorable and therefore we use standard deviation.

现在看看哪种说法更有利,因此我们使用标准差。

So in this python article, we are going to build a function for finding the SD.

因此,在这篇Python文章中,我们将构建一个用于查找SD的函数。

So the following function can be used while working on a program with big data which is very useful and help you a lot.

因此,在处理具有大数据的程序时可以使用以下功能,这非常有用,对您有很大帮助。

So here is the function code:

所以这是功能代码:

def stdv(X):
    mean = sum(X)/len(X)
    tot = 0.0
    for x in X:
        tot = tot + (x - mean)**2
    return (tot/len(X))**0.5

# main code
#  a simple data-set 
sample = [1, 2, 3, 4, 5] 
print("Standard Deviation of the sample is: ", stdv(sample))

sample = [1, 2, 3, -4, -5] 
print("Standard Deviation of the sample is: ", stdv(sample))

sample = [10, -20, 30, -40, 50] 
print("Standard Deviation of the sample is: ", stdv(sample))

Output:

输出:

Standard Deviation of the sample is:  1.4142135623730951 
Standard Deviation of the sample is:  3.2619012860600183 
Standard Deviation of the sample is:  32.61901286060018 


翻译自: https://www.includehelp.com/python/find-standard-deviation.aspx

python二分法查找程序

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值