Skip to content

Commit 1852168

Browse files
Merge branch 'stdlib-js:develop' into chisquare/stdev
2 parents f702114 + c0d9c76 commit 1852168

File tree

105 files changed

+8031
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+8031
-26
lines changed

lib/node_modules/@stdlib/math/base/special/negalucasf/lib/main.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@
2323
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2424
var isIntegerf = require( '@stdlib/math/base/assert/is-integerf' );
2525
var absf = require( '@stdlib/math/base/special/absf' );
26+
var MAX_LUCAS = require( '@stdlib/constants/float32/max-safe-nth-lucas' );
2627
var NEGALUCAS = require( './negalucas.json' );
2728

2829

29-
// VARIABLES //
30-
31-
var MAX_LUCAS = 34;
32-
33-
3430
// MAIN //
3531

3632
/**

lib/node_modules/@stdlib/math/base/special/negalucasf/manifest.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"libpath": [],
3838
"dependencies": [
3939
"@stdlib/math/base/napi/unary",
40-
"@stdlib/math/base/special/labs"
40+
"@stdlib/math/base/special/labs",
41+
"@stdlib/constants/float32/max-safe-nth-lucas"
4142
]
4243
},
4344
{
@@ -51,7 +52,8 @@
5152
"libraries": [],
5253
"libpath": [],
5354
"dependencies": [
54-
"@stdlib/math/base/special/labs"
55+
"@stdlib/math/base/special/labs",
56+
"@stdlib/constants/float32/max-safe-nth-lucas"
5557
]
5658
},
5759
{
@@ -65,7 +67,8 @@
6567
"libraries": [],
6668
"libpath": [],
6769
"dependencies": [
68-
"@stdlib/math/base/special/labs"
70+
"@stdlib/math/base/special/labs",
71+
"@stdlib/constants/float32/max-safe-nth-lucas"
6972
]
7073
}
7174
]

lib/node_modules/@stdlib/math/base/special/negalucasf/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "stdlib/math/base/special/negalucasf.h"
2020
#include "stdlib/math/base/special/labs.h"
21-
#define STDLIB_CONSTANT_FLOAT32_MAX_SAFE_NTH_LUCAS 34
21+
#include "stdlib/constants/float32/max_safe_nth_lucas.h"
2222

2323
static const int32_t negalucasf_value[ 35 ] = {
2424
2,

lib/node_modules/@stdlib/stats/base/dists/lognormal/variance/README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,101 @@ for ( i = 0; i < 10; i++ ) {
134134

135135
<!-- /.examples -->
136136

137+
<!-- C interface documentation. -->
138+
139+
* * *
140+
141+
<section class="c">
142+
143+
## C APIs
144+
145+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
146+
147+
<section class="intro">
148+
149+
</section>
150+
151+
<!-- /.intro -->
152+
153+
<!-- C usage documentation. -->
154+
155+
<section class="usage">
156+
157+
### Usage
158+
159+
```c
160+
#include "stdlib/stats/base/dists/lognormal/variance.h"
161+
```
162+
163+
#### stdlib_base_dists_lognormal_variance( mu, sigma )
164+
165+
Returns the variance for a lognormal distribution with location `mu` and scale `sigma`.
166+
167+
```c
168+
double out = stdlib_base_dists_lognormal_variance( 0.0, 1.0 );
169+
// returns ~4.671
170+
```
171+
172+
The function accepts the following arguments:
173+
174+
- **mu**: `[in] double` location parameter.
175+
- **sigma**: `[in] double` scale parameter.
176+
177+
```c
178+
double stdlib_base_dists_lognormal_variance( const double mu, const double sigma );
179+
```
180+
181+
</section>
182+
183+
<!-- /.usage -->
184+
185+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
186+
187+
<section class="notes">
188+
189+
</section>
190+
191+
<!-- /.notes -->
192+
193+
<!-- C API usage examples. -->
194+
195+
<section class="examples">
196+
197+
### Examples
198+
199+
```c
200+
#include "stdlib/stats/base/dists/lognormal/variance.h"
201+
#include <stdlib.h>
202+
#include <stdio.h>
203+
204+
static double random_uniform( const double min, const double max ) {
205+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
206+
return min + ( v*(max-min) );
207+
}
208+
209+
int main( void ) {
210+
double sigma;
211+
double mu;
212+
double y;
213+
int i;
214+
215+
for ( i = 0; i < 25; i++ ) {
216+
mu = random_uniform( 0.0, 10.0 ) - 5.0;
217+
sigma = random_uniform( 0.0, 20.0 );
218+
y = stdlib_base_dists_lognormal_variance( mu, sigma );
219+
printf( "µ: %lf, σ: %lf, Var(X;µ,σ): %lf\n", mu, sigma, y );
220+
}
221+
}
222+
```
223+
224+
</section>
225+
226+
<!-- /.examples -->
227+
228+
</section>
229+
230+
<!-- /.c -->
231+
137232
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
138233

139234
<section class="references">

lib/node_modules/@stdlib/stats/base/dists/lognormal/variance/benchmark/benchmark.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24+
var Float64Array = require( '@stdlib/array/float64' );
2425
var randu = require( '@stdlib/random/base/randu' );
2526
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2627
var EPS = require( '@stdlib/constants/float64/eps' );
@@ -32,15 +33,22 @@ var variance = require( './../lib' );
3233

3334
bench( pkg, function benchmark( b ) {
3435
var sigma;
36+
var len;
3537
var mu;
3638
var y;
3739
var i;
3840

41+
len = 100;
42+
mu = new Float64Array( len );
43+
sigma = new Float64Array( len );
44+
for ( i = 0; i < len; i++ ) {
45+
mu[ i ] = ( randu() * 100.0 ) - 50.0;
46+
sigma[ i ] = ( randu() * 20.0 ) + EPS;
47+
}
48+
3949
b.tic();
4050
for ( i = 0; i < b.iterations; i++ ) {
41-
mu = ( randu()*100.0 ) - 50.0;
42-
sigma = ( randu()*20.0 ) + EPS;
43-
y = variance( mu, sigma );
51+
y = variance( mu[ i % len ], sigma[ i % len ] );
4452
if ( isnan( y ) ) {
4553
b.fail( 'should not return NaN' );
4654
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var Float64Array = require( '@stdlib/array/float64' );
26+
var tryRequire = require( '@stdlib/utils/try-require' );
27+
var randu = require( '@stdlib/random/base/randu' );
28+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
29+
var EPS = require( '@stdlib/constants/float64/eps' );
30+
var pkg = require( './../package.json' ).name;
31+
32+
33+
// VARIABLES //
34+
35+
var variance = tryRequire( resolve( __dirname, './../lib/native.js' ) );
36+
var opts = {
37+
'skip': ( variance instanceof Error )
38+
};
39+
40+
41+
// MAIN //
42+
43+
bench( pkg+'::native', opts, function benchmark( b ) {
44+
var sigma;
45+
var len;
46+
var mu;
47+
var y;
48+
var i;
49+
50+
len = 100;
51+
mu = new Float64Array( len );
52+
sigma = new Float64Array( len );
53+
for ( i = 0; i < len; i++ ) {
54+
mu[ i ] = ( randu() * 100.0 ) - 50.0;
55+
sigma[ i ] = ( randu() * 20.0 ) + EPS;
56+
}
57+
58+
b.tic();
59+
for ( i = 0; i < b.iterations; i++ ) {
60+
y = variance( mu[ i % len ], sigma[ i % len ] );
61+
if ( isnan( y ) ) {
62+
b.fail( 'should not return NaN' );
63+
}
64+
}
65+
b.toc();
66+
if ( isnan( y ) ) {
67+
b.fail( 'should not return NaN' );
68+
}
69+
b.pass( 'benchmark finished' );
70+
b.end();
71+
});

0 commit comments

Comments
 (0)