Skip to content

Commit 21f2041

Browse files
committed
refactor!: reorder parameters
BREAKING CHANGE: switch order of `mean` and `correction` parameters To migrate, users should swap `mean` and `correction` arguments. This change ensures that the `*varm*` function signatures follow similar conventions as found in binary APIs, such as those for computing the covariance, where the `mean` parameter immediately precedes the array argument. --- 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - 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: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent 3e03d59 commit 21f2041

File tree

23 files changed

+237
-237
lines changed

23 files changed

+237
-237
lines changed

lib/node_modules/@stdlib/stats/strided/dvarmtk/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
9898
var dvarmtk = require( '@stdlib/stats/strided/dvarmtk' );
9999
```
100100

101-
#### dvarmtk( N, mean, correction, x, strideX )
101+
#### dvarmtk( N, correction, mean, x, strideX )
102102

103103
Computes the [variance][variance] of a double-precision floating-point strided array `x` provided a known `mean` and using a one-pass textbook algorithm.
104104

@@ -107,7 +107,7 @@ var Float64Array = require( '@stdlib/array/float64' );
107107

108108
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
109109

110-
var v = dvarmtk( x.length, 1.0/3.0, 1, x, 1 );
110+
var v = dvarmtk( x.length, 1, 1.0/3.0, x, 1 );
111111
// returns ~4.3333
112112
```
113113

@@ -126,7 +126,7 @@ var Float64Array = require( '@stdlib/array/float64' );
126126

127127
var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] );
128128

129-
var v = dvarmtk( 4, 1.25, 1, x, 2 );
129+
var v = dvarmtk( 4, 1, 1.25, x, 2 );
130130
// returns 6.25
131131
```
132132

@@ -140,7 +140,7 @@ var Float64Array = require( '@stdlib/array/float64' );
140140
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
141141
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
142142

143-
var v = dvarmtk( 4, 1.25, 1, x1, 2 );
143+
var v = dvarmtk( 4, 1, 1.25, x1, 2 );
144144
// returns 6.25
145145
```
146146

@@ -153,7 +153,7 @@ var Float64Array = require( '@stdlib/array/float64' );
153153

154154
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
155155

156-
var v = dvarmtk.ndarray( x.length, 1.0/3.0, 1, x, 1, 0 );
156+
var v = dvarmtk.ndarray( x.length, 1, 1.0/3.0, x, 1, 0 );
157157
// returns ~4.33333
158158
```
159159

@@ -168,7 +168,7 @@ var Float64Array = require( '@stdlib/array/float64' );
168168

169169
var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
170170

171-
var v = dvarmtk.ndarray( 4, 1.25, 1, x, 2, 1 );
171+
var v = dvarmtk.ndarray( 4, 1, 1.25, x, 2, 1 );
172172
// returns 6.25
173173
```
174174

@@ -202,7 +202,7 @@ var x = discreteUniform( 10, -50, 50, {
202202
});
203203
console.log( x );
204204

205-
var v = dvarmtk( x.length, 0.0, 1, x, 1 );
205+
var v = dvarmtk( x.length, 1, 0.0, x, 1 );
206206
console.log( v );
207207
```
208208

@@ -236,51 +236,51 @@ console.log( v );
236236
#include "stdlib/stats/strided/dvarmtk.h"
237237
```
238238

239-
#### stdlib_strided_dvarmtk( N, mean, correction, \*X, strideX )
239+
#### stdlib_strided_dvarmtk( N, correction, mean, \*X, strideX )
240240

241241
Computes the [variance][variance] of a double-precision floating-point strided array provided a known `mean` and using a one-pass textbook algorithm.
242242

243243
```c
244244
const double x[] = { 1.0, -2.0, 2.0 };
245245

246-
double v = stdlib_strided_dvarmtk( 3, 1.0/3.0, 1.0, x, 1 );
246+
double v = stdlib_strided_dvarmtk( 3, 1.0, 1.0/3.0, x, 1 );
247247
// returns ~4.3333
248248
```
249249
250250
The function accepts the following arguments:
251251
252252
- **N**: `[in] CBLAS_INT` number of indexed elements.
253-
- **mean**: `[in] double` mean.
254253
- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
254+
- **mean**: `[in] double` mean.
255255
- **X**: `[in] double*` input array.
256256
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
257257
258258
```c
259-
double stdlib_strided_dvarmtk( const CBLAS_INT N, const double mean, const double correction, const double *X, const CBLAS_INT strideX );
259+
double stdlib_strided_dvarmtk( const CBLAS_INT N, const double correction, const double mean, const double *X, const CBLAS_INT strideX );
260260
```
261261

262-
#### stdlib_strided_dvarmtk_ndarray( N, mean, correction, \*X, strideX, offsetX )
262+
#### stdlib_strided_dvarmtk_ndarray( N, correction, mean, \*X, strideX, offsetX )
263263

264264
Computes the [variance][variance] of a double-precision floating-point strided array provided a known `mean` and using a one-pass textbook algorithm and alternative indexing semantics.
265265

266266
```c
267267
const double x[] = { 1.0, -2.0, 2.0 };
268268

269-
double v = stdlib_strided_dvarmtk_ndarray( 3, 1.0/3.0, 1.0, x, 1, 0 );
269+
double v = stdlib_strided_dvarmtk_ndarray( 3, 1.0, 1.0/3.0, x, 1, 0 );
270270
// returns ~4.3333
271271
```
272272
273273
The function accepts the following arguments:
274274
275275
- **N**: `[in] CBLAS_INT` number of indexed elements.
276-
- **mean**: `[in] double` mean.
277276
- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
277+
- **mean**: `[in] double` mean.
278278
- **X**: `[in] double*` input array.
279279
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
280280
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
281281
282282
```c
283-
double stdlib_strided_dvarmtk_ndarray( const CBLAS_INT N, const double mean, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
283+
double stdlib_strided_dvarmtk_ndarray( const CBLAS_INT N, const double correction, const double mean, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
284284
```
285285

286286
</section>
@@ -316,7 +316,7 @@ int main( void ) {
316316
const int strideX = 2;
317317

318318
// Compute the variance:
319-
double v = stdlib_strided_dvarmtk( N, 4.5, 1, x, strideX );
319+
double v = stdlib_strided_dvarmtk( N, 1, 4.5, x, strideX );
320320

321321
// Print the result:
322322
printf( "sample variance: %lf\n", v );

lib/node_modules/@stdlib/stats/strided/dvarmtk/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function createBenchmark( len ) {
5454

5555
b.tic();
5656
for ( i = 0; i < b.iterations; i++ ) {
57-
v = dvarmtk( x.length, 0.0, 1, x, 1 );
57+
v = dvarmtk( x.length, 1, 0.0, x, 1 );
5858
if ( isnan( v ) ) {
5959
b.fail( 'should not return NaN' );
6060
}

lib/node_modules/@stdlib/stats/strided/dvarmtk/benchmark/benchmark.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function createBenchmark( len ) {
5959

6060
b.tic();
6161
for ( i = 0; i < b.iterations; i++ ) {
62-
v = dvarmtk( x.length, 0.0, 1, x, 1 );
62+
v = dvarmtk( x.length, 1, 0.0, x, 1 );
6363
if ( isnan( v ) ) {
6464
b.fail( 'should not return NaN' );
6565
}

lib/node_modules/@stdlib/stats/strided/dvarmtk/benchmark/benchmark.ndarray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function createBenchmark( len ) {
5454

5555
b.tic();
5656
for ( i = 0; i < b.iterations; i++ ) {
57-
v = dvarmtk( x.length, 0.0, 1, x, 1, 0 );
57+
v = dvarmtk( x.length, 1, 0.0, x, 1, 0 );
5858
if ( isnan( v ) ) {
5959
b.fail( 'should not return NaN' );
6060
}

lib/node_modules/@stdlib/stats/strided/dvarmtk/benchmark/benchmark.ndarray.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function createBenchmark( len ) {
5959

6060
b.tic();
6161
for ( i = 0; i < b.iterations; i++ ) {
62-
v = dvarmtk( x.length, 0.0, 1, x, 1, 0 );
62+
v = dvarmtk( x.length, 1, 0.0, x, 1, 0 );
6363
if ( isnan( v ) ) {
6464
b.fail( 'should not return NaN' );
6565
}

lib/node_modules/@stdlib/stats/strided/dvarmtk/benchmark/c/benchmark.length.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static double benchmark1( int iterations, int len ) {
108108
t = tic();
109109
for ( i = 0; i < iterations; i++ ) {
110110
// cppcheck-suppress uninitvar
111-
v = stdlib_strided_dvarmtk( len, 0.0, 1, x, 1 );
111+
v = stdlib_strided_dvarmtk( len, 1, 0.0, x, 1 );
112112
if ( v != v ) {
113113
printf( "should not return NaN\n" );
114114
break;
@@ -142,7 +142,7 @@ static double benchmark2( int iterations, int len ) {
142142
t = tic();
143143
for ( i = 0; i < iterations; i++ ) {
144144
// cppcheck-suppress uninitvar
145-
v = stdlib_strided_dvarmtk_ndarray( len, 0.0, 1, x, 1, 0 );
145+
v = stdlib_strided_dvarmtk_ndarray( len, 1, 0.0, x, 1, 0 );
146146
if ( v != v ) {
147147
printf( "should not return NaN\n" );
148148
break;

lib/node_modules/@stdlib/stats/strided/dvarmtk/docs/repl.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{{alias}}( N, mean, correction, x, strideX )
2+
{{alias}}( N, correction, mean, x, strideX )
33
Computes the variance of a double-precision floating-point strided array
44
provided a known mean and using a one-pass textbook algorithm.
55

@@ -16,9 +16,6 @@
1616
N: integer
1717
Number of indexed elements.
1818

19-
mean: number
20-
Mean.
21-
2219
correction: number
2320
Degrees of freedom adjustment. Setting this parameter to a value other
2421
than `0` has the effect of adjusting the divisor during the calculation
@@ -31,6 +28,9 @@
3128
sampled from a larger population; this is commonly referred to as
3229
Bessel's correction).
3330

31+
mean: number
32+
Mean.
33+
3434
x: Float64Array
3535
Input array.
3636

@@ -46,22 +46,22 @@
4646
--------
4747
// Standard Usage:
4848
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] );
49-
> {{alias}}( x.length, 1.0/3.0, 1, x, 1 )
49+
> {{alias}}( x.length, 1, 1.0/3.0, x, 1 )
5050
~4.3333
5151

5252
// Using `N` and stride parameters:
5353
> x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] );
54-
> {{alias}}( 3, 1.0/3.0, 1, x, 2 )
54+
> {{alias}}( 3, 1, 1.0/3.0, x, 2 )
5555
~4.3333
5656

5757
// Using view offsets:
5858
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, 1.0 ] );
5959
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
60-
> {{alias}}( 3, 1.0/3.0, 1, x1, 2 )
60+
> {{alias}}( 3, 1, 1.0/3.0, x1, 2 )
6161
~4.3333
6262

6363

64-
{{alias}}.ndarray( N, mean, correction, x, strideX, offsetX )
64+
{{alias}}.ndarray( N, correction, mean, x, strideX, offsetX )
6565
Computes the variance of a double-precision floating-point strided array
6666
provided a known mean and using a one-pass textbook algorithm and
6767
alternative indexing semantics.
@@ -75,9 +75,6 @@
7575
N: integer
7676
Number of indexed elements.
7777

78-
mean: number
79-
Mean.
80-
8178
correction: number
8279
Degrees of freedom adjustment. Setting this parameter to a value other
8380
than `0` has the effect of adjusting the divisor during the calculation
@@ -90,6 +87,9 @@
9087
sampled from a larger population; this is commonly referred to as
9188
Bessel's correction).
9289

90+
mean: number
91+
Mean.
92+
9393
x: Float64Array
9494
Input array.
9595

@@ -108,12 +108,12 @@
108108
--------
109109
// Standard Usage:
110110
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] );
111-
> {{alias}}.ndarray( x.length, 1.0/3.0, 1, x, 1, 0 )
111+
> {{alias}}.ndarray( x.length, 1, 1.0/3.0, x, 1, 0 )
112112
~4.3333
113113

114114
// Using offset parameter:
115115
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, 1.0 ] );
116-
> {{alias}}.ndarray( 3, 1.0/3.0, 1, x, 2, 1 )
116+
> {{alias}}.ndarray( 3, 1, 1.0/3.0, x, 2, 1 )
117117
~4.3333
118118

119119
See Also

lib/node_modules/@stdlib/stats/strided/dvarmtk/docs/types/index.d.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ interface Routine {
2626
* Computes the variance of a double-precision floating-point strided array provided a known mean and using a one-pass textbook algorithm.
2727
*
2828
* @param N - number of indexed elements
29-
* @param mean - mean
3029
* @param correction - degrees of freedom adjustment
30+
* @param mean - mean
3131
* @param x - input array
3232
* @param strideX - stride length
3333
* @returns variance
@@ -37,17 +37,17 @@ interface Routine {
3737
*
3838
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
3939
*
40-
* var v = dvarmtk( x.length, 1.0/3.0, 1, x, 1 );
40+
* var v = dvarmtk( x.length, 1, 1.0/3.0, x, 1 );
4141
* // returns ~4.3333
4242
*/
43-
( N: number, mean: number, correction: number, x: Float64Array, strideX: number ): number;
43+
( N: number, correction: number, mean: number, x: Float64Array, strideX: number ): number;
4444

4545
/**
4646
* Computes the variance of a double-precision floating-point strided array provided a known mean and using a one-pass textbook algorithm and alternative indexing semantics.
4747
*
4848
* @param N - number of indexed elements
49-
* @param mean - mean
5049
* @param correction - degrees of freedom adjustment
50+
* @param mean - mean
5151
* @param x - input array
5252
* @param strideX - stride length
5353
* @param offsetX - starting index
@@ -58,18 +58,18 @@ interface Routine {
5858
*
5959
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
6060
*
61-
* var v = dvarmtk.ndarray( x.length, 1.0/3.0, 1, x, 1, 0 );
61+
* var v = dvarmtk.ndarray( x.length, 1, 1.0/3.0, x, 1, 0 );
6262
* // returns ~4.3333
6363
*/
64-
ndarray( N: number, mean: number, correction: number, x: Float64Array, strideX: number, offsetX: number ): number;
64+
ndarray( N: number, correction: number, mean: number, x: Float64Array, strideX: number, offsetX: number ): number;
6565
}
6666

6767
/**
6868
* Computes the variance of a double-precision floating-point strided array provided a known mean and using a one-pass textbook algorithm.
6969
*
7070
* @param N - number of indexed elements
71-
* @param mean - mean
7271
* @param correction - degrees of freedom adjustment
72+
* @param mean - mean
7373
* @param x - input array
7474
* @param strideX - stride length
7575
* @returns variance
@@ -79,15 +79,15 @@ interface Routine {
7979
*
8080
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
8181
*
82-
* var v = dvarmtk( x.length, 1.0/3.0, 1, x, 1 );
82+
* var v = dvarmtk( x.length, 1, 1.0/3.0, x, 1 );
8383
* // returns ~4.3333
8484
*
8585
* @example
8686
* var Float64Array = require( '@stdlib/array/float64' );
8787
*
8888
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
8989
*
90-
* var v = dvarmtk.ndarray( x.length, 1.0/3.0, 1, x, 1, 0 );
90+
* var v = dvarmtk.ndarray( x.length, 1, 1.0/3.0, x, 1, 0 );
9191
* // returns ~4.3333
9292
*/
9393
declare var dvarmtk: Routine;

0 commit comments

Comments
 (0)