Skip to content

Commit 14874d0

Browse files
committed
Auto-generated commit
1 parent 99360b2 commit 14874d0

34 files changed

+3564
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- [`e88f80d`](https://github.com/stdlib-js/stdlib/commit/e88f80dbfd6514e9949f7b523e703a962c780273) - add `stats/strided/dnanmidrange` [(#9374)](https://github.com/stdlib-js/stdlib/pull/9374)
1314
- [`65784f7`](https://github.com/stdlib-js/stdlib/commit/65784f785748107e1fc5d84ad75c9778422e8442) - add `stats/strided/midrange-by` [(#9328)](https://github.com/stdlib-js/stdlib/pull/9328)
1415
- [`2c30c8f`](https://github.com/stdlib-js/stdlib/commit/2c30c8fccde4aa82d60552050b8a876ffac9bc6d) - add `stats/midrange` [(#9333)](https://github.com/stdlib-js/stdlib/pull/9333)
1516
- [`f04a31d`](https://github.com/stdlib-js/stdlib/commit/f04a31de84e7201d3cb54cc39a19eee84f49b407) - add `stats/base/ndarray/stdevch` [(#9327)](https://github.com/stdlib-js/stdlib/pull/9327)
@@ -3533,6 +3534,7 @@ A total of 560 issues were closed in this release:
35333534

35343535
<details>
35353536

3537+
- [`e88f80d`](https://github.com/stdlib-js/stdlib/commit/e88f80dbfd6514e9949f7b523e703a962c780273) - **feat:** add `stats/strided/dnanmidrange` [(#9374)](https://github.com/stdlib-js/stdlib/pull/9374) _(by Sachin Pangal, Athan Reines)_
35363538
- [`8006652`](https://github.com/stdlib-js/stdlib/commit/800665265e87453d27573506d1e5f3c50e458920) - **chore:** fix C lint errors [(#9360)](https://github.com/stdlib-js/stdlib/pull/9360) _(by Geo Daoyu, Athan Reines)_
35373539
- [`b256d64`](https://github.com/stdlib-js/stdlib/commit/b256d64a727ea0a266e8fae6ffacd519b55abdb0) - **test:** add test for negative zero _(by Philipp Burckhardt)_
35383540
- [`54b804b`](https://github.com/stdlib-js/stdlib/commit/54b804bba55d0045117f48b267cae91de0d9da8d) - **chore:** fix spacing _(by Philipp Burckhardt)_

strided/dnanmidrange/README.md

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# dnanmidrange
22+
23+
> Calculate the [mid-range][mid-range] of a double-precision floating-point strided array, ignoring `NaN` values.
24+
25+
<section class="intro">
26+
27+
The [**mid-range**][mid-range], or **mid-extreme**, is the arithmetic mean of the maximum and minimum values in a data set. The measure is the midpoint of the range and a measure of central tendency.
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<section class="usage">
34+
35+
## Usage
36+
37+
```javascript
38+
var dnanmidrange = require( '@stdlib/stats/strided/dnanmidrange' );
39+
```
40+
41+
#### dnanmidrange( N, x, strideX )
42+
43+
Computes the [mid-range][mid-range] of a double-precision floating-point strided array, ignoring `NaN` values.
44+
45+
```javascript
46+
var Float64Array = require( '@stdlib/array/float64' );
47+
48+
var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
49+
50+
var v = dnanmidrange( x.length, x, 1 );
51+
// returns 0.0
52+
```
53+
54+
The function has the following parameters:
55+
56+
- **N**: number of indexed elements.
57+
- **x**: input [`Float64Array`][@stdlib/array/float64].
58+
- **strideX**: stride length for `x`.
59+
60+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [mid-range][mid-range] of every other element in `x`,
61+
62+
```javascript
63+
var Float64Array = require( '@stdlib/array/float64' );
64+
65+
var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] );
66+
67+
var v = dnanmidrange( 5, x, 2 );
68+
// returns 1.0
69+
```
70+
71+
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
72+
73+
<!-- eslint-disable stdlib/capitalized-comments -->
74+
75+
```javascript
76+
var Float64Array = require( '@stdlib/array/float64' );
77+
78+
var x0 = new Float64Array( [ 2.0, 1.0, -2.0, -2.0, 3.0, 4.0, NaN, NaN ] );
79+
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
80+
81+
var v = dnanmidrange( 4, x1, 2 );
82+
// returns 1.0
83+
```
84+
85+
#### dnanmidrange.ndarray( N, x, strideX, offsetX )
86+
87+
Computes the [mid-range][mid-range] of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
88+
89+
```javascript
90+
var Float64Array = require( '@stdlib/array/float64' );
91+
92+
var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
93+
94+
var v = dnanmidrange.ndarray( x.length, x, 1, 0 );
95+
// returns 0.0
96+
```
97+
98+
The function has the following additional parameters:
99+
100+
- **offsetX**: starting index for `x`.
101+
102+
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 [mid-range][mid-range] for every other element in `x` starting from the second element
103+
104+
```javascript
105+
var Float64Array = require( '@stdlib/array/float64' );
106+
107+
var x = new Float64Array( [ 2.0, 1.0, -2.0, -2.0, 3.0, 4.0, NaN, NaN ] );
108+
109+
var v = dnanmidrange.ndarray( 4, x, 2, 1 );
110+
// returns 1.0
111+
```
112+
113+
</section>
114+
115+
<!-- /.usage -->
116+
117+
<section class="notes">
118+
119+
## Notes
120+
121+
- If `N <= 0`, both functions return `NaN`.
122+
123+
</section>
124+
125+
<!-- /.notes -->
126+
127+
<section class="examples">
128+
129+
## Examples
130+
131+
<!-- eslint no-undef: "error" -->
132+
133+
```javascript
134+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
135+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
136+
var filledarrayBy = require( '@stdlib/array/filled-by' );
137+
var dnanmidrange = require( '@stdlib/stats/strided/dnanmidrange' );
138+
139+
function random() {
140+
if ( bernoulli( 0.8 ) < 1 ) {
141+
return NaN;
142+
}
143+
return discreteUniform( -100, 100 );
144+
}
145+
146+
var x = filledarrayBy( 100, 'float64', random );
147+
console.log( x );
148+
149+
var v = dnanmidrange( x.length, x, 1 );
150+
console.log( v );
151+
```
152+
153+
</section>
154+
155+
<!-- /.examples -->
156+
157+
<!-- C interface documentation. -->
158+
159+
* * *
160+
161+
<section class="c">
162+
163+
## C APIs
164+
165+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
166+
167+
<section class="intro">
168+
169+
</section>
170+
171+
<!-- /.intro -->
172+
173+
<!-- C usage documentation. -->
174+
175+
<section class="usage">
176+
177+
### Usage
178+
179+
```c
180+
#include "stdlib/stats/strided/dnanmidrange.h"
181+
```
182+
183+
#### stdlib_strided_dnanmidrange( N, \*X, strideX )
184+
185+
Computes the [mid-range][mid-range] of a double-precision floating-point strided array, ignoring `NaN` values.
186+
187+
```c
188+
const double x[] = { 1.0, 0.0/0.0, 3.0, -4.0 };
189+
190+
double v = stdlib_strided_dnanmidrange( 4, x, 1 );
191+
// returns -0.5
192+
```
193+
194+
The function accepts the following arguments:
195+
196+
- **N**: `[in] CBLAS_INT` number of indexed elements.
197+
- **X**: `[in] double*` input array.
198+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
199+
200+
```c
201+
double stdlib_strided_dnanmidrange( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
202+
```
203+
204+
#### stdlib_strided_dnanmidrange_ndarray( N, \*X, strideX, offsetX )
205+
206+
Computes the [mid-range][mid-range] of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
207+
208+
```c
209+
const double x[] = { 1.0, 0.0/0.0, 3.0, -4.0 };
210+
211+
double v = stdlib_strided_dnanmidrange_ndarray( 4, x, 1, 0 );
212+
// returns -0.5
213+
```
214+
215+
The function accepts the following arguments:
216+
217+
- **N**: `[in] CBLAS_INT` number of indexed elements.
218+
- **X**: `[in] double*` input array.
219+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
220+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
221+
222+
```c
223+
double stdlib_strided_dnanmidrange_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
224+
```
225+
226+
</section>
227+
228+
<!-- /.usage -->
229+
230+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
231+
232+
<section class="notes">
233+
234+
</section>
235+
236+
<!-- /.notes -->
237+
238+
<!-- C API usage examples. -->
239+
240+
<section class="examples">
241+
242+
### Examples
243+
244+
```c
245+
#include "stdlib/stats/strided/dnanmidrange.h"
246+
#include <stdio.h>
247+
248+
int main( void ) {
249+
// Create a strided array:
250+
const double x[] = { 1.0, -2.0, -3.0, 4.0, -5.0, -6.0, 7.0, 8.0, 0.0/0.0, 0.0/0.0 };
251+
252+
// Specify the number of elements:
253+
const int N = 5;
254+
255+
// Specify the stride length:
256+
const int strideX = 2;
257+
258+
// Compute the mid-range:
259+
double v = stdlib_strided_dnanmidrange( N, x, strideX );
260+
261+
// Print the result:
262+
printf( "mid-range: %lf\n", v );
263+
}
264+
```
265+
266+
</section>
267+
268+
<!-- /.examples -->
269+
270+
</section>
271+
272+
<!-- /.c -->
273+
274+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
275+
276+
<section class="related">
277+
278+
</section>
279+
280+
<!-- /.related -->
281+
282+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
283+
284+
<section class="links">
285+
286+
[mid-range]: https://en.wikipedia.org/wiki/Mid-range
287+
288+
[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64
289+
290+
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
291+
292+
</section>
293+
294+
<!-- /.links -->

0 commit comments

Comments
 (0)