Skip to content

Commit eff5cba

Browse files
committed
docs: update docs
--- 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: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - 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: passed - 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 50f27bd commit eff5cba

File tree

1 file changed

+117
-30
lines changed
  • lib/node_modules/@stdlib/stats/base/dmeanwd

1 file changed

+117
-30
lines changed

lib/node_modules/@stdlib/stats/base/dmeanwd/README.md

Lines changed: 117 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,33 @@ The [arithmetic mean][arithmetic-mean] is defined as
5151
var dmeanwd = require( '@stdlib/stats/base/dmeanwd' );
5252
```
5353

54-
#### dmeanwd( N, x, stride )
54+
#### dmeanwd( N, x, strideX )
5555

5656
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array `x` using Welford's algorithm.
5757

5858
```javascript
5959
var Float64Array = require( '@stdlib/array/float64' );
6060

6161
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
62-
var N = x.length;
6362

64-
var v = dmeanwd( N, x, 1 );
63+
var v = dmeanwd( x.length, x, 1 );
6564
// returns ~0.3333
6665
```
6766

6867
The function has the following parameters:
6968

7069
- **N**: number of indexed elements.
7170
- **x**: input [`Float64Array`][@stdlib/array/float64].
72-
- **stride**: index increment for `x`.
71+
- **strideX**: stride length for `x`.
7372

74-
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
73+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
7574

7675
```javascript
7776
var Float64Array = require( '@stdlib/array/float64' );
78-
var floor = require( '@stdlib/math/base/special/floor' );
7977

8078
var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] );
81-
var N = floor( x.length / 2 );
8279

83-
var v = dmeanwd( N, x, 2 );
80+
var v = dmeanwd( 4, x, 2 );
8481
// returns 1.25
8582
```
8683

@@ -90,45 +87,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
9087

9188
```javascript
9289
var Float64Array = require( '@stdlib/array/float64' );
93-
var floor = require( '@stdlib/math/base/special/floor' );
9490

9591
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
9692
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
9793

98-
var N = floor( x0.length / 2 );
99-
100-
var v = dmeanwd( N, x1, 2 );
94+
var v = dmeanwd( 4, x1, 2 );
10195
// returns 1.25
10296
```
10397

104-
#### dmeanwd.ndarray( N, x, stride, offset )
98+
#### dmeanwd.ndarray( N, x, strideX, offsetX )
10599

106100
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array using Welford's algorithm and alternative indexing semantics.
107101

108102
```javascript
109103
var Float64Array = require( '@stdlib/array/float64' );
110104

111105
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
112-
var N = x.length;
113106

114-
var v = dmeanwd.ndarray( N, x, 1, 0 );
107+
var v = dmeanwd.ndarray( x.length, x, 1, 0 );
115108
// returns ~0.33333
116109
```
117110

118111
The function has the following additional parameters:
119112

120-
- **offset**: starting index for `x`.
113+
- **offsetX**: starting index for `x`.
121114

122-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other value in `x` starting from the second value
115+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other element in `x` starting from the second element
123116

124117
```javascript
125118
var Float64Array = require( '@stdlib/array/float64' );
126-
var floor = require( '@stdlib/math/base/special/floor' );
127119

128120
var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
129-
var N = floor( x.length / 2 );
130121

131-
var v = dmeanwd.ndarray( N, x, 2, 1 );
122+
var v = dmeanwd.ndarray( 4, x, 2, 1 );
132123
// returns 1.25
133124
```
134125

@@ -153,18 +144,12 @@ var v = dmeanwd.ndarray( N, x, 2, 1 );
153144
<!-- eslint no-undef: "error" -->
154145

155146
```javascript
156-
var randu = require( '@stdlib/random/base/randu' );
157-
var round = require( '@stdlib/math/base/special/round' );
158-
var Float64Array = require( '@stdlib/array/float64' );
147+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
159148
var dmeanwd = require( '@stdlib/stats/base/dmeanwd' );
160149

161-
var x;
162-
var i;
163-
164-
x = new Float64Array( 10 );
165-
for ( i = 0; i < x.length; i++ ) {
166-
x[ i ] = round( (randu()*100.0) - 50.0 );
167-
}
150+
var x = discreteUniform( 10, -50, 50, {
151+
'dtype': 'float64'
152+
});
168153
console.log( x );
169154

170155
var v = dmeanwd( x.length, x, 1 );
@@ -175,6 +160,108 @@ console.log( v );
175160

176161
<!-- /.examples -->
177162

163+
<!-- C usage documentation. -->
164+
165+
<section class="usage">
166+
167+
### Usage
168+
169+
```c
170+
#include "stdlib/stats/base/dmeanwd.h"
171+
```
172+
173+
#### stdlib_strided_dmeanwd( N, \*X, strideX )
174+
175+
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array using Welford's algorithm.
176+
177+
```c
178+
const double x[] = { 1.0, -2.0, 2.0 };
179+
180+
double v = stdlib_strided_dmeanwd( 3, x, 1 );
181+
// returns ~0.333
182+
```
183+
184+
The function accepts the following arguments:
185+
186+
- **N**: `[in] CBLAS_INT` number of indexed elements.
187+
- **X**: `[in] double*` input array.
188+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
189+
190+
```c
191+
double stdlib_strided_dmeanwd( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
192+
```
193+
194+
#### stdlib_strided_dmeanwd_ndarray( N, \*X, strideX, offsetX )
195+
196+
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array using Welford's algorithm and alternative indexing semantics.
197+
198+
```c
199+
const double x[] = { 1.0, -2.0, 2.0 };
200+
201+
double v = stdlib_strided_dmeanwd_ndarray( 3, x, 1, 0 );
202+
// returns ~0.333
203+
```
204+
205+
The function accepts the following arguments:
206+
207+
- **N**: `[in] CBLAS_INT` number of indexed elements.
208+
- **X**: `[in] double*` input array.
209+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
210+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
211+
212+
```c
213+
double stdlib_strided_dmeanwd_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
214+
```
215+
216+
</section>
217+
218+
<!-- /.usage -->
219+
220+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
221+
222+
<section class="notes">
223+
224+
</section>
225+
226+
<!-- /.notes -->
227+
228+
<!-- C API usage examples. -->
229+
230+
<section class="examples">
231+
232+
### Examples
233+
234+
```c
235+
#include "stdlib/stats/base/dmeanwd.h"
236+
#include <stdint.h>
237+
#include <stdio.h>
238+
239+
int main( void ) {
240+
// Create a strided array:
241+
const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
242+
243+
// Specify the number of elements:
244+
const int N = 4;
245+
246+
// Specify the stride length:
247+
const int strideX = 2;
248+
249+
// Compute the minimum value:
250+
double v = stdlib_strided_dmeanwd( N, x, strideX );
251+
252+
// Print the result:
253+
printf( "mean: %lf\n", v );
254+
}
255+
```
256+
257+
</section>
258+
259+
<!-- /.examples -->
260+
261+
</section>
262+
263+
<!-- /.c -->
264+
178265
* * *
179266
180267
<section class="references">

0 commit comments

Comments
 (0)