@stdlib/stats-strided-nanrange 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
package/NOTICE ADDED
@@ -0,0 +1 @@
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md ADDED
@@ -0,0 +1,290 @@
1
+ <!--
2
+
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2020 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
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
32
+ # nanrange
33
+
34
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
35
+
36
+ > Calculate the [range][range] of a strided array, ignoring `NaN` values.
37
+
38
+ <section class="intro">
39
+
40
+ The [**range**][range] is defined as the difference between the maximum and minimum values.
41
+
42
+ </section>
43
+
44
+ <!-- /.intro -->
45
+
46
+ <section class="installation">
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ npm install @stdlib/stats-strided-nanrange
52
+ ```
53
+
54
+ </section>
55
+
56
+ <section class="usage">
57
+
58
+ ## Usage
59
+
60
+ ```javascript
61
+ var nanrange = require( '@stdlib/stats-strided-nanrange' );
62
+ ```
63
+
64
+ #### nanrange( N, x, strideX )
65
+
66
+ Computes the [range][range] of a strided array, ignoring `NaN` values.
67
+
68
+ ```javascript
69
+ var x = [ 1.0, -2.0, NaN, 2.0 ];
70
+ var N = x.length;
71
+
72
+ var v = nanrange( N, x, 1 );
73
+ // returns 4.0
74
+ ```
75
+
76
+ The function has the following parameters:
77
+
78
+ - **N**: number of indexed elements.
79
+ - **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
80
+ - **strideX**: stride length for `x`.
81
+
82
+ The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [range][range] of every other element in `x`,
83
+
84
+ ```javascript
85
+ var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN, NaN ];
86
+
87
+ var v = nanrange( 5, x, 2 );
88
+ // returns 6.0
89
+ ```
90
+
91
+ Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
92
+
93
+ <!-- eslint-disable stdlib/capitalized-comments, max-len -->
94
+
95
+ ```javascript
96
+ var Float64Array = require( '@stdlib/array-float64' );
97
+
98
+ var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, NaN, NaN, 4.0 ] );
99
+ var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
100
+
101
+ var v = nanrange( 4, x1, 2 );
102
+ // returns 6.0
103
+ ```
104
+
105
+ #### nanrange.ndarray( N, x, strideX, offsetX )
106
+
107
+ Computes the [range][range] of a strided array, ignoring `NaN` values and using alternative indexing semantics.
108
+
109
+ ```javascript
110
+ var x = [ 1.0, -2.0, NaN, 2.0 ];
111
+ var N = x.length;
112
+
113
+ var v = nanrange.ndarray( N, x, 1, 0 );
114
+ // returns 4.0
115
+ ```
116
+
117
+ The function has the following additional parameters:
118
+
119
+ - **offsetX**: starting index for `x`.
120
+
121
+ 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 [range][range] for every other element in the strided array starting from the second element
122
+
123
+ ```javascript
124
+ var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, NaN, NaN, 2.0, 3.0, 4.0 ];
125
+
126
+ var v = nanrange.ndarray( 5, x, 2, 1 );
127
+ // returns 6.0
128
+ ```
129
+
130
+ </section>
131
+
132
+ <!-- /.usage -->
133
+
134
+ <section class="notes">
135
+
136
+ ## Notes
137
+
138
+ - If `N <= 0`, both functions return `NaN`.
139
+ - Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array-base/accessor`][@stdlib/array/base/accessor]).
140
+ - Depending on the environment, the typed versions ([`dnanrange`][@stdlib/stats/strided/dnanrange], [`snanrange`][@stdlib/stats/strided/snanrange], etc.) are likely to be significantly more performant.
141
+
142
+ </section>
143
+
144
+ <!-- /.notes -->
145
+
146
+ <section class="examples">
147
+
148
+ ## Examples
149
+
150
+ <!-- eslint no-undef: "error" -->
151
+
152
+ ```javascript
153
+ var uniform = require( '@stdlib/random-base-uniform' );
154
+ var filledarrayBy = require( '@stdlib/array-filled-by' );
155
+ var bernoulli = require( '@stdlib/random-base-bernoulli' );
156
+ var nanrange = require( '@stdlib/stats-strided-nanrange' );
157
+
158
+ function rand() {
159
+ if ( bernoulli( 0.8 ) < 1 ) {
160
+ return NaN;
161
+ }
162
+ return uniform( -50.0, 50.0 );
163
+ }
164
+
165
+ var x = filledarrayBy( 10, 'float64', rand );
166
+ console.log( x );
167
+
168
+ var v = nanrange( x.length, x, 1 );
169
+ console.log( v );
170
+ ```
171
+
172
+ </section>
173
+
174
+ <!-- /.examples -->
175
+
176
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
177
+
178
+ <section class="related">
179
+
180
+ * * *
181
+
182
+ ## See Also
183
+
184
+ - <span class="package-name">[`@stdlib/stats-strided/dnanrange`][@stdlib/stats/strided/dnanrange]</span><span class="delimiter">: </span><span class="description">calculate the range of a double-precision floating-point strided array, ignoring NaN values.</span>
185
+ - <span class="package-name">[`@stdlib/stats-strided/nanmax`][@stdlib/stats/strided/nanmax]</span><span class="delimiter">: </span><span class="description">calculate the maximum value of a strided array, ignoring NaN values.</span>
186
+ - <span class="package-name">[`@stdlib/stats-strided/nanmin`][@stdlib/stats/strided/nanmin]</span><span class="delimiter">: </span><span class="description">calculate the minimum value of a strided array, ignoring NaN values.</span>
187
+ - <span class="package-name">[`@stdlib/stats-strided/range`][@stdlib/stats/strided/range]</span><span class="delimiter">: </span><span class="description">calculate the range of a strided array.</span>
188
+ - <span class="package-name">[`@stdlib/stats-strided/snanrange`][@stdlib/stats/strided/snanrange]</span><span class="delimiter">: </span><span class="description">calculate the range of a single-precision floating-point strided array, ignoring NaN values.</span>
189
+
190
+ </section>
191
+
192
+ <!-- /.related -->
193
+
194
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
195
+
196
+
197
+ <section class="main-repo" >
198
+
199
+ * * *
200
+
201
+ ## Notice
202
+
203
+ This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
204
+
205
+ For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
206
+
207
+ #### Community
208
+
209
+ [![Chat][chat-image]][chat-url]
210
+
211
+ ---
212
+
213
+ ## License
214
+
215
+ See [LICENSE][stdlib-license].
216
+
217
+
218
+ ## Copyright
219
+
220
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
221
+
222
+ </section>
223
+
224
+ <!-- /.stdlib -->
225
+
226
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
227
+
228
+ <section class="links">
229
+
230
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/stats-strided-nanrange.svg
231
+ [npm-url]: https://npmjs.org/package/@stdlib/stats-strided-nanrange
232
+
233
+ [test-image]: https://github.com/stdlib-js/stats-strided-nanrange/actions/workflows/test.yml/badge.svg?branch=v0.1.0
234
+ [test-url]: https://github.com/stdlib-js/stats-strided-nanrange/actions/workflows/test.yml?query=branch:v0.1.0
235
+
236
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-strided-nanrange/main.svg
237
+ [coverage-url]: https://codecov.io/github/stdlib-js/stats-strided-nanrange?branch=main
238
+
239
+ <!--
240
+
241
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/stats-strided-nanrange.svg
242
+ [dependencies-url]: https://david-dm.org/stdlib-js/stats-strided-nanrange/main
243
+
244
+ -->
245
+
246
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
247
+ [chat-url]: https://stdlib.zulipchat.com
248
+
249
+ [stdlib]: https://github.com/stdlib-js/stdlib
250
+
251
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
252
+
253
+ [umd]: https://github.com/umdjs/umd
254
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
255
+
256
+ [deno-url]: https://github.com/stdlib-js/stats-strided-nanrange/tree/deno
257
+ [deno-readme]: https://github.com/stdlib-js/stats-strided-nanrange/blob/deno/README.md
258
+ [umd-url]: https://github.com/stdlib-js/stats-strided-nanrange/tree/umd
259
+ [umd-readme]: https://github.com/stdlib-js/stats-strided-nanrange/blob/umd/README.md
260
+ [esm-url]: https://github.com/stdlib-js/stats-strided-nanrange/tree/esm
261
+ [esm-readme]: https://github.com/stdlib-js/stats-strided-nanrange/blob/esm/README.md
262
+ [branches-url]: https://github.com/stdlib-js/stats-strided-nanrange/blob/main/branches.md
263
+
264
+ [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats-strided-nanrange/main/LICENSE
265
+
266
+ [range]: https://en.wikipedia.org/wiki/Range_%28statistics%29
267
+
268
+ [mdn-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
269
+
270
+ [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
271
+
272
+ [@stdlib/array/base/accessor]: https://www.npmjs.com/package/@stdlib/array-base-accessor
273
+
274
+ <!-- <related-links> -->
275
+
276
+ [@stdlib/stats/strided/dnanrange]: https://www.npmjs.com/package/@stdlib/stats-strided-dnanrange
277
+
278
+ [@stdlib/stats/strided/nanmax]: https://www.npmjs.com/package/@stdlib/stats-strided-nanmax
279
+
280
+ [@stdlib/stats/strided/nanmin]: https://www.npmjs.com/package/@stdlib/stats-strided-nanmin
281
+
282
+ [@stdlib/stats/strided/range]: https://www.npmjs.com/package/@stdlib/stats-strided-range
283
+
284
+ [@stdlib/stats/strided/snanrange]: https://www.npmjs.com/package/@stdlib/stats-strided-snanrange
285
+
286
+ <!-- </related-links> -->
287
+
288
+ </section>
289
+
290
+ <!-- /.links -->
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import nanrange from '../docs/types/index';
3
+ export = nanrange;
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";var c=function(a,n){return function(){return n||a((n={exports:{}}).exports,n),n.exports}};var x=c(function(B,m){
2
+ var l=require('@stdlib/math-base-assert-is-nan/dist');function j(a,n,i,s){var v,u,t,f,e,r,o;if(v=n.data,u=n.accessors[0],a===1||i===0)return l(u(v,s))?NaN:0;for(e=s,o=0;o<a&&(r=u(v,e),r!==r);o++)e+=i;if(o===a)return NaN;for(f=r,t=f,o+=1,o;o<a;o++)e+=i,r=u(v,e),!l(r)&&(r<f?f=r:r>t&&(t=r));return t-f}m.exports=j
3
+ });var q=c(function(C,b){
4
+ var N=require('@stdlib/array-base-arraylike2object/dist'),y=require('@stdlib/math-base-assert-is-nan/dist'),O=x();function P(a,n,i,s){var v,u,t,f,e,r;if(a<=0)return NaN;if(f=N(n),f.accessorProtocol)return O(a,f,i,s);if(a===1||i===0)return y(n[s])?NaN:0;for(t=s,r=0;r<a&&(e=n[t],e!==e);r++)t+=i;if(r===a)return NaN;for(u=e,v=u,r+=1,r;r<a;r++)t+=i,e=n[t],!y(e)&&(e<u?u=e:e>v&&(v=e));return v-u}b.exports=P
5
+ });var p=c(function(D,g){
6
+ var R=require('@stdlib/strided-base-stride2offset/dist'),d=q();function h(a,n,i){return d(a,n,i,R(a,i))}g.exports=h
7
+ });var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),k=p(),z=q();w(k,"ndarray",z);module.exports=k;
8
+ /** @license Apache-2.0 */
9
+ /** @license Apache-2.0 */
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/accessors.js", "../lib/ndarray.js", "../lib/main.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Computes the range of a strided array, ignoring `NaN` values.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array<Function>} x.accessors - array element accessors\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {number} range\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = toAccessorArray( [ 1.0, -2.0, NaN, 2.0 ] );\n*\n* var v = nanrange( 4, arraylike2object( x ), 1, 0 );\n* // returns 4.0\n*/\nfunction nanrange( N, x, strideX, offsetX ) {\n\tvar xbuf;\n\tvar get;\n\tvar max;\n\tvar min;\n\tvar ix;\n\tvar v;\n\tvar i;\n\n\t// Cache reference to array data:\n\txbuf = x.data;\n\n\t// Cache a reference to the element accessor:\n\tget = x.accessors[ 0 ];\n\tif ( N === 1 || strideX === 0 ) {\n\t\tif ( isnan( get( xbuf, offsetX ) ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\treturn 0.0;\n\t}\n\n\tix = offsetX;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv = get( xbuf, ix );\n\t\tif ( v === v ) {\n\t\t\tbreak;\n\t\t}\n\t\tix += strideX;\n\t}\n\tif ( i === N ) {\n\t\treturn NaN;\n\t}\n\tmin = v;\n\tmax = min;\n\ti += 1;\n\tfor ( i; i < N; i++ ) {\n\t\tix += strideX;\n\t\tv = get( xbuf, ix );\n\t\tif ( isnan( v ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( v < min ) {\n\t\t\tmin = v;\n\t\t} else if ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max - min;\n}\n\n\n// EXPORTS //\n\nmodule.exports = nanrange;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar accessors = require( './accessors.js' );\n\n\n// MAIN //\n\n/**\n* Computes the range of a strided array, ignoring `NaN` values.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {number} range\n*\n* @example\n* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ];\n*\n* var v = nanrange( 5, x, 2, 1 );\n* // returns 6.0\n*/\nfunction nanrange( N, x, strideX, offsetX ) {\n\tvar max;\n\tvar min;\n\tvar ix;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn NaN;\n\t}\n\to = arraylike2object( x );\n\tif ( o.accessorProtocol ) {\n\t\treturn accessors( N, o, strideX, offsetX );\n\t}\n\tif ( N === 1 || strideX === 0 ) {\n\t\tif ( isnan( x[ offsetX ] ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\treturn 0.0;\n\t}\n\tix = offsetX;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv = x[ ix ];\n\t\tif ( v === v ) {\n\t\t\tbreak;\n\t\t}\n\t\tix += strideX;\n\t}\n\tif ( i === N ) {\n\t\treturn NaN;\n\t}\n\tmin = v;\n\tmax = min;\n\ti += 1;\n\tfor ( i; i < N; i++ ) {\n\t\tix += strideX;\n\t\tv = x[ ix ];\n\t\tif ( isnan( v ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( v < min ) {\n\t\t\tmin = v;\n\t\t} else if ( v > max ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn max - min;\n}\n\n\n// EXPORTS //\n\nmodule.exports = nanrange;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar stride2offset = require( '@stdlib/strided-base-stride2offset' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\n/**\n* Computes the range of a strided array, ignoring `NaN` values.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} strideX - stride length\n* @returns {number} variance\n*\n* @example\n* var x = [ 1.0, -2.0, NaN, 2.0 ];\n*\n* var v = nanrange( 4, x, 1 );\n* // returns 4.0\n*/\nfunction nanrange( N, x, strideX ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = nanrange;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Compute the range of a strided array, ignoring `NaN` values.\n*\n* @module @stdlib/stats-strided-nanrange\n*\n* @example\n* var nanrange = require( '@stdlib/stats-strided-nanrange' );\n*\n* var x = [ 1.0, -2.0, NaN, 2.0 ];\n* var N = x.length;\n*\n* var v = nanrange( N, x, 1 );\n* // returns 4.0\n*\n* @example\n* var nanrange = require( '@stdlib/stats-strided-nanrange' );\n*\n* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ];\n*\n* var v = nanrange.ndarray( 5, x, 2, 1 );\n* // returns 6.0\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"ndarray\": \"main.ndarray\" }\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EA0BvD,SAASC,EAAUC,EAAGC,EAAGC,EAASC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,GAJAN,EAAOH,EAAE,KAGTI,EAAMJ,EAAE,UAAW,CAAE,EAChBD,IAAM,GAAKE,IAAY,EAC3B,OAAKJ,EAAOO,EAAKD,EAAMD,CAAQ,CAAE,EACzB,IAED,EAIR,IADAK,EAAKL,EACCO,EAAI,EAAGA,EAAIV,IAChBS,EAAIJ,EAAKD,EAAMI,CAAG,EACbC,IAAMA,GAFQC,IAKnBF,GAAMN,EAEP,GAAKQ,IAAMV,EACV,MAAO,KAKR,IAHAO,EAAME,EACNH,EAAMC,EACNG,GAAK,EACCA,EAAGA,EAAIV,EAAGU,IACfF,GAAMN,EACNO,EAAIJ,EAAKD,EAAMI,CAAG,EACb,CAAAV,EAAOW,CAAE,IAGTA,EAAIF,EACRA,EAAME,EACKA,EAAIH,IACfA,EAAMG,IAGR,OAAOH,EAAMC,CACd,CAKAV,EAAO,QAAUE,ICrGjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAQ,QAAS,iCAAkC,EACnDC,EAAY,IAoBhB,SAASC,EAAUC,EAAGC,EAAGC,EAASC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKT,GAAK,EACT,MAAO,KAGR,GADAO,EAAIX,EAAkBK,CAAE,EACnBM,EAAE,iBACN,OAAOT,EAAWE,EAAGO,EAAGL,EAASC,CAAQ,EAE1C,GAAKH,IAAM,GAAKE,IAAY,EAC3B,OAAKL,EAAOI,EAAGE,CAAQ,CAAE,EACjB,IAED,EAGR,IADAG,EAAKH,EACCM,EAAI,EAAGA,EAAIT,IAChBQ,EAAIP,EAAGK,CAAG,EACLE,IAAMA,GAFQC,IAKnBH,GAAMJ,EAEP,GAAKO,IAAMT,EACV,MAAO,KAKR,IAHAK,EAAMG,EACNJ,EAAMC,EACNI,GAAK,EACCA,EAAGA,EAAIT,EAAGS,IACfH,GAAMJ,EACNM,EAAIP,EAAGK,CAAG,EACL,CAAAT,EAAOW,CAAE,IAGTA,EAAIH,EACRA,EAAMG,EACKA,EAAIJ,IACfA,EAAMI,IAGR,OAAOJ,EAAMC,CACd,CAKAV,EAAO,QAAUI,ICjGjB,IAAAW,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAU,IAmBd,SAASC,EAAUC,EAAGC,EAAGC,EAAU,CAClC,OAAOJ,EAASE,EAAGC,EAAGC,EAASL,EAAeG,EAAGE,CAAQ,CAAE,CAC5D,CAKAN,EAAO,QAAUG,ICJjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
6
+ "names": ["require_accessors", "__commonJSMin", "exports", "module", "isnan", "nanrange", "N", "x", "strideX", "offsetX", "xbuf", "get", "max", "min", "ix", "v", "i", "require_ndarray", "__commonJSMin", "exports", "module", "arraylike2object", "isnan", "accessors", "nanrange", "N", "x", "strideX", "offsetX", "max", "min", "ix", "o", "v", "i", "require_main", "__commonJSMin", "exports", "module", "stride2offset", "ndarray", "nanrange", "N", "x", "strideX", "setReadOnly", "main", "ndarray"]
7
+ }
@@ -0,0 +1,93 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2020 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
+ // TypeScript Version: 4.1
20
+
21
+ /// <reference types="@stdlib/types"/>
22
+
23
+ import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';
24
+
25
+ /**
26
+ * Input array.
27
+ */
28
+ type InputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;
29
+
30
+ /**
31
+ * Interface describing `nanrange`.
32
+ */
33
+ interface Routine {
34
+ /**
35
+ * Computes the range of a strided array, ignoring `NaN` values.
36
+ *
37
+ * @param N - number of indexed elements
38
+ * @param x - input array
39
+ * @param strideX - stride length
40
+ * @returns range
41
+ *
42
+ * @example
43
+ * var x = [ 1.0, -2.0, NaN, 2.0 ];
44
+ *
45
+ * var v = nanrange( x.length, x, 1 );
46
+ * // returns 4.0
47
+ */
48
+ ( N: number, x: InputArray, strideX: number ): number;
49
+
50
+ /**
51
+ * Computes the range of a strided array, ignoring `NaN` values and using alternative indexing semantics.
52
+ *
53
+ * @param N - number of indexed elements
54
+ * @param x - input array
55
+ * @param strideX - stride length
56
+ * @param offset - starting index
57
+ * @returns range
58
+ *
59
+ * @example
60
+ * var x = [ 1.0, -2.0, NaN, 2.0 ];
61
+ *
62
+ * var v = nanrange.ndarray( x.length, x, 1, 0 );
63
+ * // returns 4.0
64
+ */
65
+ ndarray( N: number, x: InputArray, strideX: number, offset: number ): number;
66
+ }
67
+
68
+ /**
69
+ * Computes the range of a strided array, ignoring `NaN` values.
70
+ *
71
+ * @param N - number of indexed elements
72
+ * @param x - input array
73
+ * @param strideX - stride length
74
+ * @returns range
75
+ *
76
+ * @example
77
+ * var x = [ 1.0, -2.0, NaN, 2.0 ];
78
+ *
79
+ * var v = nanrange( x.length, x, 1 );
80
+ * // returns 4.0
81
+ *
82
+ * @example
83
+ * var x = [ 1.0, -2.0, NaN, 2.0 ];
84
+ *
85
+ * var v = nanrange.ndarray( x.length, x, 1, 0 );
86
+ * // returns 4.0
87
+ */
88
+ declare var nanrange: Routine;
89
+
90
+
91
+ // EXPORTS //
92
+
93
+ export = nanrange;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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 isnan = require( '@stdlib/math-base-assert-is-nan' );
24
+
25
+
26
+ // MAIN //
27
+
28
+ /**
29
+ * Computes the range of a strided array, ignoring `NaN` values.
30
+ *
31
+ * @private
32
+ * @param {PositiveInteger} N - number of indexed elements
33
+ * @param {Object} x - input array object
34
+ * @param {Collection} x.data - input array data
35
+ * @param {Array<Function>} x.accessors - array element accessors
36
+ * @param {integer} strideX - stride length
37
+ * @param {NonNegativeInteger} offsetX - starting index
38
+ * @returns {number} range
39
+ *
40
+ * @example
41
+ * var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );
42
+ * var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
43
+ *
44
+ * var x = toAccessorArray( [ 1.0, -2.0, NaN, 2.0 ] );
45
+ *
46
+ * var v = nanrange( 4, arraylike2object( x ), 1, 0 );
47
+ * // returns 4.0
48
+ */
49
+ function nanrange( N, x, strideX, offsetX ) {
50
+ var xbuf;
51
+ var get;
52
+ var max;
53
+ var min;
54
+ var ix;
55
+ var v;
56
+ var i;
57
+
58
+ // Cache reference to array data:
59
+ xbuf = x.data;
60
+
61
+ // Cache a reference to the element accessor:
62
+ get = x.accessors[ 0 ];
63
+ if ( N === 1 || strideX === 0 ) {
64
+ if ( isnan( get( xbuf, offsetX ) ) ) {
65
+ return NaN;
66
+ }
67
+ return 0.0;
68
+ }
69
+
70
+ ix = offsetX;
71
+ for ( i = 0; i < N; i++ ) {
72
+ v = get( xbuf, ix );
73
+ if ( v === v ) {
74
+ break;
75
+ }
76
+ ix += strideX;
77
+ }
78
+ if ( i === N ) {
79
+ return NaN;
80
+ }
81
+ min = v;
82
+ max = min;
83
+ i += 1;
84
+ for ( i; i < N; i++ ) {
85
+ ix += strideX;
86
+ v = get( xbuf, ix );
87
+ if ( isnan( v ) ) {
88
+ continue;
89
+ }
90
+ if ( v < min ) {
91
+ min = v;
92
+ } else if ( v > max ) {
93
+ max = v;
94
+ }
95
+ }
96
+ return max - min;
97
+ }
98
+
99
+
100
+ // EXPORTS //
101
+
102
+ module.exports = nanrange;
package/lib/index.js ADDED
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2020 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
+ /**
22
+ * Compute the range of a strided array, ignoring `NaN` values.
23
+ *
24
+ * @module @stdlib/stats-strided-nanrange
25
+ *
26
+ * @example
27
+ * var nanrange = require( '@stdlib/stats-strided-nanrange' );
28
+ *
29
+ * var x = [ 1.0, -2.0, NaN, 2.0 ];
30
+ * var N = x.length;
31
+ *
32
+ * var v = nanrange( N, x, 1 );
33
+ * // returns 4.0
34
+ *
35
+ * @example
36
+ * var nanrange = require( '@stdlib/stats-strided-nanrange' );
37
+ *
38
+ * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ];
39
+ *
40
+ * var v = nanrange.ndarray( 5, x, 2, 1 );
41
+ * // returns 6.0
42
+ */
43
+
44
+ // MODULES //
45
+
46
+ var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
47
+ var main = require( './main.js' );
48
+ var ndarray = require( './ndarray.js' );
49
+
50
+
51
+ // MAIN //
52
+
53
+ setReadOnly( main, 'ndarray', ndarray );
54
+
55
+
56
+ // EXPORTS //
57
+
58
+ module.exports = main;
59
+
60
+ // exports: { "ndarray": "main.ndarray" }
package/lib/main.js ADDED
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2020 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 stride2offset = require( '@stdlib/strided-base-stride2offset' );
24
+ var ndarray = require( './ndarray.js' );
25
+
26
+
27
+ // MAIN //
28
+
29
+ /**
30
+ * Computes the range of a strided array, ignoring `NaN` values.
31
+ *
32
+ * @param {PositiveInteger} N - number of indexed elements
33
+ * @param {NumericArray} x - input array
34
+ * @param {integer} strideX - stride length
35
+ * @returns {number} variance
36
+ *
37
+ * @example
38
+ * var x = [ 1.0, -2.0, NaN, 2.0 ];
39
+ *
40
+ * var v = nanrange( 4, x, 1 );
41
+ * // returns 4.0
42
+ */
43
+ function nanrange( N, x, strideX ) {
44
+ return ndarray( N, x, strideX, stride2offset( N, strideX ) );
45
+ }
46
+
47
+
48
+ // EXPORTS //
49
+
50
+ module.exports = nanrange;
package/lib/ndarray.js ADDED
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2020 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 arraylike2object = require( '@stdlib/array-base-arraylike2object' );
24
+ var isnan = require( '@stdlib/math-base-assert-is-nan' );
25
+ var accessors = require( './accessors.js' );
26
+
27
+
28
+ // MAIN //
29
+
30
+ /**
31
+ * Computes the range of a strided array, ignoring `NaN` values.
32
+ *
33
+ * @param {PositiveInteger} N - number of indexed elements
34
+ * @param {NumericArray} x - input array
35
+ * @param {integer} strideX - stride length
36
+ * @param {NonNegativeInteger} offsetX - starting index
37
+ * @returns {number} range
38
+ *
39
+ * @example
40
+ * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ];
41
+ *
42
+ * var v = nanrange( 5, x, 2, 1 );
43
+ * // returns 6.0
44
+ */
45
+ function nanrange( N, x, strideX, offsetX ) {
46
+ var max;
47
+ var min;
48
+ var ix;
49
+ var o;
50
+ var v;
51
+ var i;
52
+
53
+ if ( N <= 0 ) {
54
+ return NaN;
55
+ }
56
+ o = arraylike2object( x );
57
+ if ( o.accessorProtocol ) {
58
+ return accessors( N, o, strideX, offsetX );
59
+ }
60
+ if ( N === 1 || strideX === 0 ) {
61
+ if ( isnan( x[ offsetX ] ) ) {
62
+ return NaN;
63
+ }
64
+ return 0.0;
65
+ }
66
+ ix = offsetX;
67
+ for ( i = 0; i < N; i++ ) {
68
+ v = x[ ix ];
69
+ if ( v === v ) {
70
+ break;
71
+ }
72
+ ix += strideX;
73
+ }
74
+ if ( i === N ) {
75
+ return NaN;
76
+ }
77
+ min = v;
78
+ max = min;
79
+ i += 1;
80
+ for ( i; i < N; i++ ) {
81
+ ix += strideX;
82
+ v = x[ ix ];
83
+ if ( isnan( v ) ) {
84
+ continue;
85
+ }
86
+ if ( v < min ) {
87
+ min = v;
88
+ } else if ( v > max ) {
89
+ max = v;
90
+ }
91
+ }
92
+ return max - min;
93
+ }
94
+
95
+
96
+ // EXPORTS //
97
+
98
+ module.exports = nanrange;
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@stdlib/stats-strided-nanrange",
3
+ "version": "0.1.0",
4
+ "description": "Calculate the range of a strided array, ignoring NaN values.",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "The Stdlib Authors",
8
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9
+ },
10
+ "contributors": [
11
+ {
12
+ "name": "The Stdlib Authors",
13
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
+ }
15
+ ],
16
+ "main": "./lib",
17
+ "directories": {
18
+ "doc": "./docs",
19
+ "lib": "./lib",
20
+ "dist": "./dist"
21
+ },
22
+ "types": "./docs/types",
23
+ "scripts": {},
24
+ "homepage": "https://stdlib.io",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git://github.com/stdlib-js/stats-strided-nanrange.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/stdlib-js/stdlib/issues"
31
+ },
32
+ "dependencies": {
33
+ "@stdlib/array-base-arraylike2object": "^0.2.1",
34
+ "@stdlib/math-base-assert-is-nan": "^0.2.2",
35
+ "@stdlib/strided-base-stride2offset": "^0.1.0",
36
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2"
37
+ },
38
+ "devDependencies": {},
39
+ "engines": {
40
+ "node": ">=0.10.0",
41
+ "npm": ">2.7.0"
42
+ },
43
+ "os": [
44
+ "aix",
45
+ "darwin",
46
+ "freebsd",
47
+ "linux",
48
+ "macos",
49
+ "openbsd",
50
+ "sunos",
51
+ "win32",
52
+ "windows"
53
+ ],
54
+ "keywords": [
55
+ "stdlib",
56
+ "stdmath",
57
+ "statistics",
58
+ "stats",
59
+ "mathematics",
60
+ "math",
61
+ "maximum",
62
+ "max",
63
+ "minimum",
64
+ "min",
65
+ "range",
66
+ "extremes",
67
+ "dispersion",
68
+ "domain",
69
+ "extent",
70
+ "strided",
71
+ "strided array",
72
+ "array"
73
+ ],
74
+ "funding": {
75
+ "type": "opencollective",
76
+ "url": "https://opencollective.com/stdlib"
77
+ }
78
+ }