stdm

stdm(v, m)

Compute the sample standard deviation of a vector v with known mean m. Note: Julia does not ignore NaN values in the computation.

Examples

Sure! Here are some examples for the stdm function in Julia:

  1. Compute standard deviation with known mean:

    julia> v = [1, 2, 3, 4, 5];
    julia> m = mean(v);
    julia> stdm(v, m)
    1.4142135623730951

    This example calculates the sample standard deviation of vector v with a known mean m.

  2. Handle NaN values in the computation:

    julia> v = [1, 2, NaN, 4, 5];
    julia> m = mean(v);
    julia> stdm(v, m)
    1.8708286933869707

    The stdm function takes into account NaN values in the computation of standard deviation.

  3. Compute standard deviation with a different mean:
    julia> v = [10, 20, 30, 40, 50];
    julia> m = 25;
    julia> stdm(v, m)
    14.142135623730951

    You can compute the standard deviation of v with a mean value different from the actual mean of the vector.

Common mistake example:

julia> v = [1, 2, 3, 4, 5];
julia> m = 10;
julia> stdm(v, m)
ERROR: DomainError with NaN result:
mean(x::AbstractArray{T}) where T<:Real at statistics.jl:53 computed NaN

In this example, the provided mean value m is incorrect, resulting in a NaN value in the computation of the standard deviation. Make sure to provide the correct mean value to avoid such errors.

See Also

cummax, eigmax, findmax, hist, hist!, hist2d, hist2d!, histrange, indmax, maxabs, maxabs!, maximum!, mean, mean!, median, median!, minabs, minabs!, minimum!, minmax, quantile!, realmax, std, stdm,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: