std

paddle. std ( x: Tensor, axis: int | Sequence[int] | None = None, unbiased: bool | None = None, keepdim: bool = False, name: str | None = None, *, correction: float = 1, out: Tensor | None = None ) → Tensor [source]

Computes the standard-deviation of x along axis .

Note

Alias Support: 1. The parameter name input can be used as an alias for x. 2. The parameter name dim can be used as an alias for axis.

Parameters
  • x (Tensor) – The input Tensor with data type float16, float32, float64.

  • axis (int|list|tuple|None, optional) – The axis along which to perform standard-deviation calculations. axis should be int, list(int) or tuple(int). If axis is a list/tuple of dimension(s), standard-deviation is calculated along all element(s) of axis . axis or element(s) of axis should be in range [-D, D), where D is the dimensions of x . If axis or element(s) of axis is less than 0, it works the same way as \(axis + D\) . If axis is None, standard-deviation is calculated over all elements of x. Default is None.

  • unbiased (bool, optional) – Whether to use the unbiased estimation. If unbiased is True, the standard-deviation is calculated via the unbiased estimator. If unbiased is True, the divisor used in the computation is \(N - 1\), where \(N\) represents the number of elements along axis , otherwise the divisor is \(N\). Default is True.

  • keepdim (bool, optional) – Whether to reserve the reduced dimension(s) in the output Tensor. If keepdim is True, the dimensions of the output Tensor is the same as x except in the reduced dimensions(it is of size 1 in this case). Otherwise, the shape of the output Tensor is squeezed in axis . Default is False.

  • name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to api_guide_Name.

  • correction (int|float, optional) – Difference between the sample size and sample degrees of freedom. Defaults to 1 (Bessel’s correction). If unbiased is specified, this parameter is ignored.

  • out (Tensor|None, optional) – Output tensor. Default is None.

Returns

Tensor, results of standard-deviation along axis of x, with the same data type as x.

Examples

>>> import paddle

>>> x = paddle.to_tensor([[1.0, 2.0, 3.0], [1.0, 4.0, 5.0]])
>>> out1 = paddle.std(x)
>>> print(out1.numpy())
1.6329932

>>> out2 = paddle.std(x, unbiased=False)
>>> print(out2.numpy())
1.490712

>>> out3 = paddle.std(x, axis=1)
>>> print(out3.numpy())
[1.       2.081666]

>>> out4 = paddle.std(x=x, keepdim=True, correction=1.5)
>>> print(out4.numpy())
[[1.721326]]

>>> out5 = paddle.std(input=x, dim=[0, 1])
>>> print(out5.numpy())
1.6329932