Skip to content

Commit 604046b

Browse files
committed
docs: add c documentation
--- 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 ---
1 parent efd793a commit 604046b

File tree

1 file changed

+113
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dmeanvarpn

1 file changed

+113
-0
lines changed

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

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,119 @@ console.log( out );
226226

227227
<!-- /.examples -->
228228

229+
<!-- C usage documentation. -->
230+
231+
<section class="usage">
232+
233+
### Usage
234+
235+
```c
236+
#include "stdlib/stats/base/dmeanvarpn.h"
237+
```
238+
239+
#### stdlib_strided_dmeanvarpn( N, correction, \*X, strideX, \*Out, strideOut )
240+
241+
Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array using a two-pass algorithm.
242+
243+
```c
244+
const double x[] = { 1.0, -2.0, 2.0 };
245+
double out[] = { 0.0, 0.0 }
246+
247+
stdlib_strided_dmeanvarpn( 3, 1.0, x, 1, out, 1 );
248+
```
249+
250+
The function accepts the following arguments:
251+
252+
- **N**: `[in] CBLAS_INT` number of indexed elements.
253+
- **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+
- **X**: `[in] double*` input array.
255+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
256+
- **Out**: `[out] double*` output array.
257+
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
258+
259+
```c
260+
double stdlib_strided_dmeanvarpn( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT strideOut );
261+
```
262+
263+
#### stdlib_strided_dmeanvarpn( N, correction, \*X, strideX, offsetX, \*Out, strideOut, offsetOut )
264+
265+
Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array using a two-pass algorithm and alternative indexing semantics.
266+
267+
```c
268+
const double x[] = { 1.0, -2.0, 2.0 };
269+
double out[] = { 0.0, 0.0 }
270+
271+
stdlib_strided_dmeanvarpn_ndarray( 3, 1.0, x, 1, 0, out, 1, 0 );
272+
```
273+
274+
The function accepts the following arguments:
275+
276+
- **N**: `[in] CBLAS_INT` number of indexed elements.
277+
- **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).
278+
- **X**: `[in] double*` input array.
279+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
280+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
281+
- **Out**: `[out] double*` output array.
282+
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
283+
- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`.
284+
285+
```c
286+
double stdlib_strided_dmeanvarpn_ndarray( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut );
287+
```
288+
289+
</section>
290+
291+
<!-- /.usage -->
292+
293+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
294+
295+
<section class="notes">
296+
297+
</section>
298+
299+
<!-- /.notes -->
300+
301+
<!-- C API usage examples. -->
302+
303+
<section class="examples">
304+
305+
### Examples
306+
307+
```c
308+
#include "stdlib/stats/base/dmeanvarpn.h"
309+
#include <stdio.h>
310+
311+
int main( void ) {
312+
// Create a strided array:
313+
const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
314+
315+
// Create an output array:
316+
double out[] = { 0.0, 0.0 };
317+
318+
// Specify the number of elements:
319+
const int N = 4;
320+
321+
// Specify the stride lengths:
322+
const int strideX = 2;
323+
const int strideOut = 1;
324+
325+
// Compute the mean and variance:
326+
stdlib_strided_dmeanvarpn( N, 1.0, x, strideX, out, strideOut );
327+
328+
// Print the result:
329+
printf( "sample mean: %lf\n", out[ 0 ] );
330+
printf( "sample variance: %lf\n", out[ 1 ] );
331+
}
332+
```
333+
334+
</section>
335+
336+
<!-- /.examples -->
337+
338+
</section>
339+
340+
<!-- /.c -->
341+
229342
* * *
230343
231344
<section class="references">

0 commit comments

Comments
 (0)