Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f98af75
Added tests that f([a, b, c, d]) works where f is a pdf/pmf, a cdf, a…
bbbales2 Sep 15, 2020
cf8ead1
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Sep 15, 2020
ab8718f
Removed unnecessary templating
bbbales2 Sep 15, 2020
c86968b
Merge branch 'bugfix/issue-1861-2' of https://github.com/stan-dev/mat…
bbbales2 Sep 15, 2020
4d511de
Merge commit '76bcc0fc4f65301304d594cf4006de92dd0ee420' into HEAD
yashikno Sep 15, 2020
6ddeaa7
[Jenkins] auto-formatting by clang-format version 6.0.1-14 (tags/RELE…
stan-buildbot Sep 15, 2020
fb2c639
Updated test_as_vector to handle fvar<double> and fvar<fvar<double>>
bbbales2 Sep 17, 2020
63f6ad8
[Jenkins] auto-formatting by clang-format version 6.0.1-14 (tags/RELE…
stan-buildbot Sep 17, 2020
b40f439
Fixed bug with handling vectors in test_repeat_as_vector (Issue #1861)
bbbales2 Sep 17, 2020
08eb67a
Avoid 1 + small number underflows in skew normal (Issue #1861)
bbbales2 Sep 18, 2020
7996270
Merge commit 'ed6ab4bd5ea47b9f9f40ec9e5d42f5a5b456dd5c' into HEAD
yashikno Sep 18, 2020
ae32445
[Jenkins] auto-formatting by clang-format version 6.0.1-14 (tags/RELE…
stan-buildbot Sep 18, 2020
f10d9ec
Updating discrete range and tests (Issue #1861)
bbbales2 Sep 21, 2020
87886df
Merge branch 'bugfix/issue-1861-2' of https://github.com/stan-dev/mat…
bbbales2 Sep 21, 2020
a50a7fa
Merge remote-tracking branch 'origin/develop' into bugfix/issue-1861-2
bbbales2 Sep 21, 2020
f612588
Fixed discrete range bug (Issue #1861)
bbbales2 Sep 21, 2020
ebc5432
Changed the gumbel and negative binomial tests to make the numerics e…
bbbales2 Sep 22, 2020
371ccd3
Updated comments and warning messages (Issue #1861)
bbbales2 Sep 23, 2020
97b59db
Merge commit 'c0686c673cafea0991501027b4cc80b097a420d7' into HEAD
yashikno Sep 23, 2020
8d9ac84
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Sep 23, 2020
7a9d1a2
Added back negative binomial test and switched to expect_near_rel (Is…
bbbales2 Sep 30, 2020
5e26e99
Merge branch 'develop' into bugfix/issue-1861-2
bbbales2 Sep 30, 2020
ba59e35
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Sep 30, 2020
0c891f3
Made logistic test slightly numerically easier (Issue #1861)
bbbales2 Sep 30, 2020
8574678
Merge commit '2cf4310702eec1b14a355d883e704af0b788abd8' into HEAD
yashikno Sep 30, 2020
cbe96eb
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Sep 30, 2020
42fd448
Made probability unit tests easier for negative binomial (Issue #1861)
bbbales2 Oct 1, 2020
500a870
Merge branch 'bugfix/issue-1861-2' of https://github.com/stan-dev/mat…
bbbales2 Oct 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions stan/math/prim/prob/discrete_range_cdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,16 @@ double discrete_range_cdf(const T_y& y, const T_lower& lower,
if (y_dbl < lower_vec[n]) {
return 0;
}
if (y_dbl > upper_vec[n]) {
return 1;
}
}

double cdf(1.0);
for (size_t n = 0; n < N; n++) {
const double y_dbl = y_vec[n];
const double lower_dbl = lower_vec[n];
const double upper_dbl = upper_vec[n];
cdf *= (y_dbl - lower_dbl + 1) / (upper_dbl - lower_dbl + 1);
if (y_dbl <= upper_vec[n]) {
const double lower_dbl = lower_vec[n];
const double upper_dbl = upper_vec[n];
cdf *= (y_dbl - lower_dbl + 1) / (upper_dbl - lower_dbl + 1);
}
}
return cdf;
}
Expand Down
13 changes: 6 additions & 7 deletions stan/math/prim/prob/discrete_range_lccdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,19 @@ double discrete_range_lccdf(const T_y& y, const T_lower& lower,

for (size_t n = 0; n < N; ++n) {
const int y_dbl = y_vec[n];
if (y_dbl < lower_vec[n]) {
return 0;
}
if (y_dbl > upper_vec[n]) {
if (y_dbl >= upper_vec[n]) {
return LOG_ZERO;
}
}

double ccdf(0.0);
for (size_t n = 0; n < N; n++) {
const int y_dbl = y_vec[n];
const int lower_dbl = lower_vec[n];
const int upper_dbl = upper_vec[n];
ccdf += log(upper_dbl - y_dbl) - log(upper_dbl - lower_dbl + 1);
if (y_dbl >= lower_vec[n]) {
const int lower_dbl = lower_vec[n];
const int upper_dbl = upper_vec[n];
ccdf += log(upper_dbl - y_dbl) - log(upper_dbl - lower_dbl + 1);
}
}
return ccdf;
}
Expand Down
11 changes: 5 additions & 6 deletions stan/math/prim/prob/discrete_range_lcdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,16 @@ double discrete_range_lcdf(const T_y& y, const T_lower& lower,
if (y_dbl < lower_vec[n]) {
return LOG_ZERO;
}
if (y_dbl > upper_vec[n]) {
return 0;
}
}

double cdf(0.0);
for (size_t n = 0; n < N; n++) {
const int y_dbl = y_vec[n];
const int lower_dbl = lower_vec[n];
const int upper_dbl = upper_vec[n];
cdf += log(y_dbl - lower_dbl + 1) - log(upper_dbl - lower_dbl + 1);
if (y_dbl < upper_vec[n]) {
const int lower_dbl = lower_vec[n];
const int upper_dbl = upper_vec[n];
cdf += log(y_dbl - lower_dbl + 1) - log(upper_dbl - lower_dbl + 1);
}
}
return cdf;
}
Expand Down
12 changes: 8 additions & 4 deletions stan/math/prim/prob/skew_normal_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ return_type_t<T_y, T_loc, T_scale, T_shape> skew_normal_lpdf(
if (include_summand<propto, T_y, T_loc, T_scale>::value) {
logp -= y_minus_mu_over_sigma * y_minus_mu_over_sigma / 2.0;
}
logp += log(erfc(-alpha_dbl * y_minus_mu_over_sigma / SQRT_TWO));

T_partials_return log_erfc_alpha_z
= log(erfc(-alpha_dbl * y_minus_mu_over_sigma / SQRT_TWO));

logp += log_erfc_alpha_z;

T_partials_return deriv_logerf
= TWO_OVER_SQRT_PI
* exp(-alpha_dbl * y_minus_mu_over_sigma / SQRT_TWO * alpha_dbl
* y_minus_mu_over_sigma / SQRT_TWO)
/ (1 + erf(alpha_dbl * y_minus_mu_over_sigma / SQRT_TWO));
* exp(-square(alpha_dbl * y_minus_mu_over_sigma / SQRT_TWO)
- log_erfc_alpha_z);

if (!is_constant_all<T_y>::value) {
ops_partials.edge1_.partials_[n]
+= -y_minus_mu_over_sigma / sigma_dbl
Expand Down
6 changes: 5 additions & 1 deletion test/prob/discrete_range/discrete_range_ccdf_log_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ class AgradCcdfLogDiscreteRange : public AgradCcdfLogTest {
stan::return_type_t<T_y, T_lower, T_upper> ccdf_log_function(
const T_y& y, const T_lower& lower, const T_upper& upper, const T3&,
const T4&, const T5&) {
if (y < lower || y > upper) {
if (y < lower) {
return 0.0;
}

if (y >= upper) {
return stan::math::LOG_ZERO;
}

Expand Down
6 changes: 5 additions & 1 deletion test/prob/discrete_range/discrete_range_cdf_log_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ class AgradCdfLogDiscreteRange : public AgradCdfLogTest {
double cdf_log_function(const T_y& y, const T_lower& lower,
const T_upper& upper, const T3&, const T4&,
const T5&) {
if (y < lower || y > upper) {
if (y < lower) {
return stan::math::LOG_ZERO;
}

if (y > upper) {
return 0.0;
}

return log((y - lower + 1.0) / (upper - lower + 1.0));
}
};
6 changes: 5 additions & 1 deletion test/prob/discrete_range/discrete_range_cdf_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ class AgradCdfDiscreteRange : public AgradCdfTest {
typename T5>
double cdf_function(const T_y& y, const T_lower& lower, const T_upper& upper,
const T3&, const T4&, const T5&) {
if (y < lower || y > upper) {
if (y < lower) {
return 0;
}

if (y >= upper) {
return 1;
}

return (y - lower + 1.0) / (upper - lower + 1.0);
}
};
6 changes: 2 additions & 4 deletions test/prob/gumbel/gumbel_cdf_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ class AgradCdfGumbel : public AgradCdfTest {
0.0006179789893310934986195216040530260548886143651007); // expected
// cdf

param[0] = -3.5; // y
param[0] = -1.5; // y
param[1] = 1.9; // mu
param[2] = 7.2; // beta
parameters.push_back(param);
cdf.push_back(
0.1203922620798295861862650786832089422663975274508450); // expected
// cdf
cdf.push_back(0.20118031381610754216); // expected cdf
}

void invalid_values(vector<size_t>& index, vector<double>& value) {
Expand Down
4 changes: 2 additions & 2 deletions test/prob/logistic/logistic_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class AgradDistributionsLogistic : public AgradDistributionTest {

param[0] = -1.0; // y
param[1] = 0.2; // mu
param[2] = 0.25; // sigma
param[2] = 0.5; // sigma
parameters.push_back(param);
log_prob.push_back(-3.430097773556644469295); // expected log_prob
log_prob.push_back(-1.8805251237479538862); // expected log_prob
}

void invalid_values(vector<size_t>& index, vector<double>& value) {
Expand Down
10 changes: 4 additions & 6 deletions test/prob/neg_binomial/neg_binomial_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class AgradDistributionsNegBinomial : public AgradDistributionTest {
parameters.push_back(param);
log_prob.push_back(-142.6147368129045105434); // expected log_prob

param[0] = 13;
param[1] = 1e11;
param[2] = 1e10;
param[0] = 10;
param[1] = 1e6;
param[2] = 1e5;
parameters.push_back(param);
log_prob.push_back(-2.6185576442208003); // expected log_prob
log_prob.push_back(-2.0785666431081630812); // expected log_prob
}

void invalid_values(vector<size_t>& index, vector<double>& value) {
Expand Down Expand Up @@ -75,8 +75,6 @@ class AgradDistributionsNegBinomial : public AgradDistributionTest {
using stan::math::multiply_log;
using std::log;

if (alpha > 1e10)
return -lgamma(n + 1.0) + multiply_log(n, alpha / beta) - alpha / beta;
if (n != 0)
return binomial_coefficient_log<
typename stan::scalar_type<T_shape>::type>(n + alpha - 1.0, n)
Expand Down
Loading