某一元素的标准差

发布于 2024-12-13 21:40:55 字数 210 浏览 2 评论 0原文

当我尝试执行时

StandardDeviation[{1}]

出现错误,

StandardDeviation::shlen: "The argument {1} should have at least two elements"

但一个元素的 std 为 0,不是吗?

When I try to execute

StandardDeviation[{1}]

I get an error

StandardDeviation::shlen: "The argument {1} should have at least two elements"

But std of one element is 0, isn't it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

各空 2024-12-20 21:40:55

标准差通常定义为方差的无偏估计量的平方根:

enter image此处的描述

您可以轻松地看到,对于单个示例,N=1,您会得到0/0,这是未定义的。因此,Mathematica 中单个样本的标准差是未定义的。

现在,根据您的约定,您可能需要为单个样本定义标准差(返回 Null 或某个值或 0)。下面的示例向您展示了如何为单个示例定义它。

std[x_List] := Which[(Length[x] == 1), 0, True, StandardDeviation[x]]
std[{1}]
Out[1]= 0

The standard deviation is commonly defined as the square-root of the unbiased estimator of the variance:

enter image description here

You can easily see that for a single sample, N=1 and you get 0/0, which is undefined. Hence your standard deviation is undefined for a single sample in Mathematica.

Now depending on your conventions, you might want to define a standard deviation for a single sample (either return Null or some value or 0). Here's an example that shows you how to define it for a single sample.

std[x_List] := Which[(Length[x] == 1), 0, True, StandardDeviation[x]]
std[{1}]
Out[1]= 0
丑丑阿 2024-12-20 21:40:55

常数的标准差为零。

一个样本的估计标准差是未定义的。

The standard deviation of a constant is zero.

The estimated standard deviation of one sample is undefined.

月光色 2024-12-20 21:40:55

如果您想要一些形式:

p[x_] := DiracDelta[x - mu];
expValue = Integrate[x p[x] , {x, -Infinity, Infinity}]
stdDev = Sqrt[Integrate[(x - expValue)^2 p[x] , {x, -Infinity, Infinity}]]

(*
-> ConditionalExpression[mu, mu \[Element] Reals]
-> ConditionalExpression[0, mu \[Element] Reals]
*)

编辑

或者更好,使用 Mathematica ProbabilityDistribution[]

dist = ProbabilityDistribution[DiracDelta[x - mu], {x, -Infinity, Infinity}];
{Mean[dist], StandardDeviation[dist]}

(*
 -> { mu, ConditionalExpression[0, mu \[Element] Reals]}
*)

If you want some formality:

p[x_] := DiracDelta[x - mu];
expValue = Integrate[x p[x] , {x, -Infinity, Infinity}]
stdDev = Sqrt[Integrate[(x - expValue)^2 p[x] , {x, -Infinity, Infinity}]]

(*
-> ConditionalExpression[mu, mu \[Element] Reals]
-> ConditionalExpression[0, mu \[Element] Reals]
*)

Edit

Or better, using Mathematica ProbabilityDistribution[]:

dist = ProbabilityDistribution[DiracDelta[x - mu], {x, -Infinity, Infinity}];
{Mean[dist], StandardDeviation[dist]}

(*
 -> { mu, ConditionalExpression[0, mu \[Element] Reals]}
*)
小ぇ时光︴ 2024-12-20 21:40:55

如果您的总体规模是一个元素,那么总体的标准差将为 0。但是,标准差通常用于样本,而不是整个总体,因此您不必除以样本中的元素数量,而是使用除以元素数量减一。这是由于对样本而不是总体执行计算时固有的误差造成的。

对规模为 1 的总体执行标准差计算绝对没有意义,我认为这就是混乱的根源。如果您知道您的总体仅包含一个元素,那么找出该元素的标准差是毫无意义的,因此通常您会看到单个元素的标准差写为未定义。

If your population size is one element, then yes the standard deviation of your population will be 0. However typically standard deviations are used on samples, and not on the entire population, so instead of dividing by the number of elements in the sample, you divide by the number of elements minus one. This is due to the error inherent in performing calculations on a sample, rather than a population.

Performing a calculation of the standard deviation over a population of size 1 makes absolutely no sense, which I think is where the confusion is coming from. If you know that your population contains only one element then finding out the standard deviation of that element is pointless, so generally you will see the standard deviation of a single element written as undefined.

野心澎湃 2024-12-20 21:40:55

标准差——衡量实际值与给定集合平均值的偏差的标准——对于一个元素的列表没有任何意义(如果需要,可以将其设置为 0)。

Standard deviation - which is a measure for the deviation of the actual value from the average of a given set - for a list of one element doesn't make any sense (you can set it to 0 if you want).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文