Skip to content

Commit fca081c

Browse files
fix(main.c): made changes in main.c
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 145cc72 commit fca081c

File tree

1 file changed

+13
-9
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/logistic/logcdf/src

1 file changed

+13
-9
lines changed

lib/node_modules/@stdlib/stats/base/dists/logistic/logcdf/src/main.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
#include "stdlib/math/base/special/log1p.h"
2323
#include "stdlib/math/base/special/exp.h"
2424

25+
double log1pexp( const double x ) {
26+
if ( x <= 18.0 ) {
27+
return stdlib_base_log1p( stdlib_base_exp( x ) );
28+
}
29+
if ( x > 33.3 ) {
30+
return x;
31+
}
32+
// Case: 18.0 < z <= 33.3
33+
return x + stdlib_base_exp( -x );
34+
}
2535

2636
/**
2737
* Evaluates the logarithm of the cumulative distribution function (CDF) for a logistic distribution with location parameter `mu` and scale parameter `s` at a value `x`.
@@ -64,13 +74,7 @@ double stdlib_base_dists_logistic_logcdf( const double x, const double mu, const
6474
if ( s == 0.0 ) {
6575
return ( x < mu ) ? STDLIB_CONSTANT_FLOAT64_NINF : 0.0;
6676
}
67-
z = -( ( x - mu ) / s );
68-
if ( z <= 18.0 ) {
69-
return -stdlib_base_log1p( stdlib_base_exp(z) );
70-
}
71-
if ( z > 33.3 ) {
72-
return -z;
73-
}
74-
// Case: 18.0 < z <= 33.3
75-
return -( x + stdlib_base_exp( -z ) );
77+
z = ( x - mu ) / s;
78+
return -log1pexp( -z );
7679
}
80+

0 commit comments

Comments
 (0)