Skip to content

Issue with xt:stddev being very slow #1826

Open
@kritchie

Description

@kritchie

Hi, first of all thanks for the hard work on the library. It's pretty cool.

I'm using the xtensor-python but I wasn't sure to post it here of in xtensor-python.
I figured it would be more relevant here.

I have an issue with the stddev function. To keep it simple I have this code which takes as input a Numpy array of shape [5000, 1] (so basically a vector of 5K elements) and computes the mean and the standard deviation of that vector of doubles.

xt::pyarray<double> process(xt::pyarray<double>& m)
{

    xt::pyarray<double> features = {0., 0.};

    features[0] = xt::mean(m)(0, 0);
    features[1] = xt::stddev(m)(0, 0);

    return features;
}

My issue is that this code runs pretty fast when I comment the xt:stddev line (computing only the xt::mean).

features[0] = xt::mean(m)(0, 0);
// features[1] = xt::stddev(m)(0, 0);

But it's extremely slow (by a factor of 100x) when I left it uncommented. So I don't understand why adding the computation of the stddev is so slow.

There's a high chance that I'm doing something wrong here but I'm not sure what exactly. Is there a different and specific way in which the stddev method is supposed to be called ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions