Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/655: Standard deviation and variance #753

Closed
wants to merge 3 commits into from

Commits on Nov 12, 2019

  1. Issue/655: Standard deviation and variance

    This PR implements std and var methods using the same
    method as used for var_axis, std_axis.
    The variance is computed by flattened the array into
    a 1D array of the .len() of original array.
    
    The return type is scalar A instead of Array<A, D:Smaller>
    
    An attempt was made to refactor var_axis to use var, but this
    resulted in a performance regression so original implementations
    are kept and we accept some code duplication.
    
    ```
        pub fn var_axis(&self, axis: Axis, ddof: A) -> Array<A, D::Smaller>
        where
            A: Float + FromPrimitive,
            D: RemoveAxis,
        {
            let mut sum_sq = Array::<A, D::Smaller>::zeros(self.dim.remove_axis(axis));
    
            for (lane, sum) in self.lanes(axis).into_iter().zip(sum_sq.iter_mut()) {
                *sum = lane.var(ddof);
            }
            sum_sq
        }
    ```
    allmywatts committed Nov 12, 2019
    Configuration menu
    Copy the full SHA
    26cdba3 View commit details
    Browse the repository at this point in the history

Commits on Dec 9, 2019

  1. Use var in var_axis

    LukeMathWalker committed Dec 9, 2019
    Configuration menu
    Copy the full SHA
    0c8662d View commit details
    Browse the repository at this point in the history

Commits on Jan 20, 2020

  1. Merge pull request #1 from LukeMathWalker/varstd

    Use `var` in var_axis
    allmywatts committed Jan 20, 2020
    Configuration menu
    Copy the full SHA
    c2eeb25 View commit details
    Browse the repository at this point in the history