diff --git a/velox/functions/prestosql/Probability.h b/velox/functions/prestosql/Probability.h index 01df8923cf720..3d2d981fa13ef 100644 --- a/velox/functions/prestosql/Probability.h +++ b/velox/functions/prestosql/Probability.h @@ -111,7 +111,6 @@ struct InverseBinomialCDFFunction { boost::math::binomial_distribution<> dist(numOfTrials, successProb); result = boost::math::quantile(dist, p); - result = numOfTrials; } }; diff --git a/velox/functions/prestosql/tests/ProbabilityTest.cpp b/velox/functions/prestosql/tests/ProbabilityTest.cpp index aae94cba2d964..67ae99398952c 100644 --- a/velox/functions/prestosql/tests/ProbabilityTest.cpp +++ b/velox/functions/prestosql/tests/ProbabilityTest.cpp @@ -166,23 +166,19 @@ TEST_F(ProbabilityTest, inverseBinomialCDF) { p); }; - //EXPECT_EQ(0, invBinomialCDF(5, 0.5, 0.03125)); - EXPECT_EQ(5, invBinomialCDF(5, 0.5, 0.03125)); + EXPECT_EQ(0, invBinomialCDF(5, 0.5, 0.03125)); EXPECT_EQ(41, invBinomialCDF(41, 0.2, 1.0)); - //EXPECT_EQ(3, invBinomialCDF(5, 0.5, 0.8125)); - EXPECT_EQ(5, invBinomialCDF(5, 0.5, 0.8125)); + EXPECT_EQ(3, invBinomialCDF(5, 0.5, 0.8125)); EXPECT_EQ(3, invBinomialCDF(3, 0.8403, 0.5)); - //EXPECT_EQ(62, invBinomialCDF(200, 0.3, 0.6)); - EXPECT_EQ(200, invBinomialCDF(200, 0.3, 0.6)); - //EXPECT_EQ(0, invBinomialCDF(79, 0.6, 0.0)); - EXPECT_EQ(79, invBinomialCDF(79, 0.6, 0.0)); + EXPECT_EQ(62, invBinomialCDF(200, 0.3, 0.6)); + EXPECT_EQ(0, invBinomialCDF(79, 0.6, 0.0)); EXPECT_EQ(std::nullopt, invBinomialCDF(std::nullopt, 0.6, 0.0)); EXPECT_EQ(std::nullopt, invBinomialCDF(11, std::nullopt, 0.22)); EXPECT_EQ(std::nullopt, invBinomialCDF(134, 0.6, std::nullopt)); EXPECT_EQ( std::nullopt, invBinomialCDF(std::nullopt, std::nullopt, std::nullopt)); - //Test invalid inputs for numberOfTrials. + // Test invalid inputs for numberOfTrials. VELOX_ASSERT_THROW( invBinomialCDF(0, 0.5, 0.3), "numberOfTrials must be greater than 0"); VELOX_ASSERT_THROW(