Skip to content

Commit 19d14f2

Browse files
fix: changes in example and other files
--- 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: passed - 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: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - 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: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - 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 bcfc934 commit 19d14f2

File tree

8 files changed

+23
-52
lines changed

8 files changed

+23
-52
lines changed

lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ for ( i = 0; i < 10; i++ ) {
161161

162162
#### stdlib_base_dists_geometric_cdf( x, p )
163163

164-
Evaluates evaluating the [cumulative distribution function][cdf] of a [geometric][geometric-distribution] distribution with success probability `p`.
164+
Evaluates the [cumulative distribution function][cdf] of a [geometric][geometric-distribution] distribution with success probability `p`.
165165

166166
```c
167167
double out = stdlib_base_dists_geometric_cdf( 2.0, 0.5 );
@@ -197,7 +197,6 @@ double stdlib_base_dists_geometric_cdf( const double x, const double p );
197197
198198
```c
199199
#include "stdlib/stats/base/dists/geometric/cdf.h"
200-
#include "stdlib/constants/float64/eps.h"
201200
#include <stdlib.h>
202201
#include <stdio.h>
203202
#include <math.h>
@@ -215,7 +214,7 @@ int main( void ) {
215214
216215
for ( i = 0; i < 25; i++ ) {
217216
x = random_uniform( 0.0, 40.0 );
218-
p = random_uniform( 0.0, 1.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
217+
p = random_uniform( 0.0, 1.0 );
219218
y = stdlib_base_dists_geometric_cdf( x, p );
220219
printf( "x: %lf, p: %lf, F(x;p): %lf\n", x, p, y );
221220
}

lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/benchmark/benchmark.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ var bench = require( '@stdlib/bench' );
2424
var Float64Array = require( '@stdlib/array/float64' );
2525
var randu = require( '@stdlib/random/base/randu' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27-
var EPS = require( '@stdlib/constants/float64/eps' );
2827
var pkg = require( './../package.json' ).name;
2928
var cdf = require( './../lib' );
3029

@@ -43,7 +42,7 @@ bench( pkg, function benchmark( b ) {
4342
p = new Float64Array( len );
4443
for ( i = 0; i < len; i++ ) {
4544
x[ i % len ] = randu()*40.0;
46-
p[ i % len ] = ( randu()*1.0 ) + EPS;
45+
p[ i % len ] = ( randu()*1.0 );
4746
}
4847

4948
b.tic();

lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/benchmark/benchmark.native.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ var bench = require( '@stdlib/bench' );
2525
var Float64Array = require( '@stdlib/array/float64' );
2626
var randu = require( '@stdlib/random/base/randu' );
2727
var isnan = require( '@stdlib/math/base/assert/is-nan' );
28-
var EPS = require( '@stdlib/constants/float64/eps' );
2928
var tryRequire = require( '@stdlib/utils/try-require' );
3029
var pkg = require( './../package.json' ).name;
3130

@@ -52,7 +51,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
5251
p = new Float64Array( len );
5352
for ( i = 0; i < len; i++ ) {
5453
x[ i % len ] = randu()*40.0;
55-
p[ i % len ] = ( randu()*1.0 ) + EPS;
54+
p[ i % len ] = ( randu()*1.0 );
5655
}
5756

5857
b.tic();

lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/benchmark/c/benchmark.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/geometric/cdf.h"
20-
#include "stdlib/constants/float64/eps.h"
2120
#include <stdlib.h>
2221
#include <stdio.h>
2322
#include <math.h>
@@ -102,7 +101,7 @@ static double benchmark( void ) {
102101

103102
for ( i = 0; i < 100; i++ ) {
104103
x[ i ] = random_uniform( 0.0, 40.0 );
105-
p[ i ] = random_uniform( 0.0, 1.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
104+
p[ i ] = random_uniform( 0.0, 1.0 );
106105
}
107106

108107
t = tic();

lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/examples/c/example.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/geometric/cdf.h"
20-
#include "stdlib/constants/float64/eps.h"
2120
#include <stdlib.h>
2221
#include <stdio.h>
2322
#include <math.h>
@@ -35,7 +34,7 @@ int main( void ) {
3534

3635
for ( i = 0; i < 25; i++ ) {
3736
x = random_uniform( 0.0, 40.0 );
38-
p = random_uniform( 0.0, 1.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
37+
p = random_uniform( 0.0, 1.0 );
3938
y = stdlib_base_dists_geometric_cdf( x, p );
4039
printf( "x: %lf, p: %lf, F(x;p): %lf\n", x, p, y );
4140
}

lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/include/stdlib/stats/base/dists/geometric/cdf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Evaluates the cumulative distribution function (CDF) for the geometric distribution with probability parameter p.
30+
* Evaluates the cumulative distribution function (CDF) for the geometric distribution with success probability `p` at a value `x`.
3131
*/
3232
double stdlib_base_dists_geometric_cdf( const double x, const double p );
3333

lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/manifest.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"libpath": [],
5959
"dependencies": [
6060
"@stdlib/math/base/assert/is-nan",
61-
"@stdlib/constants/float64/eps",
6261
"@stdlib/constants/float64/pinf",
6362
"@stdlib/math/base/special/floor",
6463
"@stdlib/math/base/special/pow"
@@ -77,7 +76,6 @@
7776
"libpath": [],
7877
"dependencies": [
7978
"@stdlib/math/base/assert/is-nan",
80-
"@stdlib/constants/float64/eps",
8179
"@stdlib/constants/float64/pinf",
8280
"@stdlib/math/base/special/floor",
8381
"@stdlib/math/base/special/pow"

lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/src/main.c

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,54 +21,32 @@
2121
#include "stdlib/constants/float64/pinf.h"
2222
#include "stdlib/math/base/special/floor.h"
2323
#include "stdlib/math/base/special/pow.h"
24-
#include <math.h>
2524

2625
/**
2726
* Evaluates the cumulative distribution function (CDF) for a geometric distribution with success probability `p` at a value `x`.
2827
*
29-
* @param {number} x - input value
30-
* @param {Probability} p - success probability
31-
* @returns {Probability} evaluated CDF
28+
* @param x input value
29+
* @param p success probability
30+
* @returns evaluated CDF
3231
*
3332
* @example
34-
* var y = cdf( 2.0, 0.5 );
33+
* double y = stdlib_base_dists_geometric_cdf( 2.0, 0.5 );
3534
* // returns 0.875
36-
*
37-
* @example
38-
* var y = cdf( 2.0, 0.1 );
39-
* // returns ~0.271
40-
*
41-
* @example
42-
* var y = cdf( -1.0, 0.5 );
43-
* // returns 0.0
44-
*
45-
* @example
46-
* var y = cdf( NaN, 0.5 );
47-
* // returns NaN
48-
*
49-
* @example
50-
* var y = cdf( 0.0, NaN );
51-
* // returns NaN
52-
*
53-
* @example
54-
* // Invalid probability
55-
* var y = cdf( 2.0, 1.4 );
56-
* // returns NaN
5735
*/
5836
double stdlib_base_dists_geometric_cdf( const double x, const double p ) {
59-
if (
60-
stdlib_base_is_nan( x ) ||
61-
stdlib_base_is_nan( p ) ||
62-
p < 0.0 ||
63-
p > 1.0
64-
) {
65-
return 0.0/0.0; // NaN
66-
}
67-
if ( x < 0.0 ) {
68-
return 0.0;
69-
}
37+
if (
38+
stdlib_base_is_nan( x ) ||
39+
stdlib_base_is_nan( p ) ||
40+
p < 0.0 ||
41+
p > 1.0
42+
) {
43+
return 0.0/0.0; // NaN
44+
}
45+
if ( x < 0.0 ) {
46+
return 0.0;
47+
}
7048
if( x == STDLIB_CONSTANT_FLOAT64_PINF ){
7149
return 1.0;
7250
}
73-
return 1.0 - stdlib_base_pow( 1.0 - p, stdlib_base_floor( x ) + 1.0 );
51+
return 1.0 - stdlib_base_pow( 1.0 - p, stdlib_base_floor( x ) + 1.0 );
7452
}

0 commit comments

Comments
 (0)