Skip to content

TensorTests.cs and Tensor.cs StdDev calculates Variance rather than Standard deviations #110381

Closed
@xela-trawets

Description

Description

The StdDev routine lacks a square root at the end. The test also lacks the square root.
Easy to fix, rename to Variance and add a new function to calaculate the STdDev by taking the square root.

However... This is normally* -( see what we did there) used for sample sets and not usually populations So it might be best to add and option to define the sample or popukation usage,, but that is a nuance compare to delivering the wrong thing entirely. (difference being adjustment for degrees of freedom which is division by N or (N-1) - because estimating the mean "uses up" some fraction of the variation)

Reproduction Steps

Calculate the StdDev of almost anything
var t = Enumerable.Range(-32, 64).Select(x => 1.0 * x).ToArray();
var tt = new ReadOnlyTensorSpan (t.AsSpan());
var s = Tensor.StdDev(tt);
Console.WriteLine(s);

341.25

Expected behavior

Something like 18.47

Actual behavior

341.25

Regression?

No response

Known Workarounds

Take the square root,

Configuration

dotnet 9

Other information

No response

Metadata

Assignees

No one assigned

    Labels

    area-System.Numerics.Tensorsin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions