当前位置:网站首页>torch. Var (), sample variance, parent variance

torch. Var (), sample variance, parent variance

2022-06-11 08:12:00 Interval

Classification of variance

 Insert picture description here
There is an obvious difference between the two , Why is there such a difference ?
There are two differences , The two differences are interrelated , An integral :

  1. How much data . The above one is only a part of the sample , The following one has complete data , Overall , Mother .
  2. Purpose . You want to calculate the variance of this part of the data , Or estimate the variance of the population . If it's the former , Then use the matrix variance formula , If it's the latter , Use the sample variance formula .

Further explanation : When we only have part of the sample , Obviously, we cannot estimate the variance of the complete data ( The following formula ), therefore , The above formula is actually an approximate estimate , But the expectation of this estimate is equal to the variance of the complete data , Unbiased estimation .

torch.var

import torch

torch.var Both variances can be calculated , It depends on a parameter , namely unbiased, Unbiased meaning . The default value is true, in other words , The default goal is to sample the estimated population , The sample variance formula above is used , It calculates the sample variance .

Our actual combat view is as follows :

a=torch.tensor([1.0,-1])
torch.var(a)# The denominator is divided by 1.

give the result as follows :

tensor(2.)

a=torch.tensor([1.0,-1])
torch.var(a,unbiased=False)# The denominator is divided by 2.

give the result as follows :

tensor(1.)

原网站

版权声明
本文为[Interval]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020514399148.html