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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wrong result with xt::quantile
#2651
Comments
Hello @ThibHlln , thanks for reporting! Looking into your 1st example, if you increase the cout precision before your example with std::cout << qth << std::endl;
// {0.34999999999999998, 0.65000000000000002},
// {0.09999999999999998, 0.90000000000000002}} While std::cout << qth_ << std::endl;
// {{ 0.35, 0.1 },
// { 0.65, 0.9 }} If I use // "hand-written" quantiles
xt::xtensor<double, 2> qth_ = {{0.34999999999999998, 0.65000000000000002},,
{0.09999999999999998, 0.90000000000000002}}; I get the same result Now the weird part, is at the |
@ThibHlln forget everything I said.
The "weird" part I was seeing was an artifact of copy-pasting without noticing one was the transposed of the other. |
Hi @AntoinePrv , Thanks a lot for looking into this. Apologies for the mistake in my MWE. |
If I'm not wrong, we do have the consistent results regardless of whether we use a view, or an hand-written array.
Indeed. So it looks like like that the function gives a different output depending on whether the proba afterwards is larger or smaller, which is definitely a bug! I'll investigate. |
Yes, absolutely. My diagnosis was wrong.
Thank you very much! |
@ThibHlln I think I am getting starting to get confused with the example... Right now I don't get any wrong output. |
Sure, here is an updated MWE: xt::xtensor<double, 2> prd = {{927., 932., 935., 943., 944., 944., 945., 948., 952.,
962., 968., 968., 969., 969., 974., 981., 993., 994.,
994., 1003., 1007., 1008., 1008., 1012., 1013., 1014., 1014.,
1017., 1019., 1020., 1023., 1026., 1026., 1028., 1030., 1032.,
1039., 1047., 1071., 1080., 1085., 1088., 1111., 1112., 1117.,
1119., 1128., 1130., 1209., 1309., 1426.}};
std::cout << xt::quantile(prd, {0.10}, 1) << std::endl;
// {{ 944.}}
std::cout << xt::quantile(prd, {0.35}, 1) << std::endl;
// {{ 994.}}
std::cout << xt::quantile(prd, {0.65}, 1) << std::endl;
// {{ 1027.}}
std::cout << xt::quantile(prd, {0.35, 0.10}, 1) << std::endl;
// {{ 994.},
// { 944.}}
// WRONG RESULT FOR PROBA=0.35
std::cout << xt::quantile(prd, {0.35, 0.65}, 1) << std::endl;
// {{ 1000.5}, <<<< ?!?
// { 1027. }}
// WRONG RESULT FOR PROBA=0.35
std::cout << xt::quantile(prd, {0.65, 0.35}, 1) << std::endl;
// {{ 1027. },
// { 1000.5}} <<<< ?!?
|
Thanks @ThibHlln. The issue seems to come from |
Hi,
I seem to be getting the wrong result with
xt::quantile
in some occasions (i.e. with some specific data like the one below, and only on linux with GCC so far).For example:
I need to pre-compute my quantiles based on some confidence levels:
Then, when I use these pre-computed quantiles with
xt::quantile
I don't get the right result:And if I work on 1D tensors instead, I get a result half wrong:
I am unsure whether I am doing something wrong or if this is a bug?
I first thought it was because I was passing views for the probas parameter of
xt::quantile
, but as shown above this works with the "hand-written" tensor.I also tried adding
xt::eval
when pre-computing my quantiles, but it does not seem to solve the problem.I would appreciate any help/ideas on this problem.
Thanks.
For reference, with numpy:
The text was updated successfully, but these errors were encountered: