{"_id":"@stdlib/stats-strided-meanpn","_rev":"2-3e989cf169d8e92a158457ff984ce420","name":"@stdlib/stats-strided-meanpn","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@stdlib/stats-strided-meanpn","version":"0.1.0","keywords":["stdlib","stdmath","statistics","stats","mathematics","math","average","avg","mean","arithmetic mean","central tendency","strided","strided array","array"],"author":{"url":"https://github.com/stdlib-js/stdlib/graphs/contributors","name":"The Stdlib Authors"},"license":"Apache-2.0","_id":"@stdlib/stats-strided-meanpn@0.1.0","maintainers":[{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"}],"contributors":[{"url":"https://github.com/stdlib-js/stdlib/graphs/contributors","name":"The Stdlib Authors"}],"homepage":"https://stdlib.io","bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"os":["aix","darwin","freebsd","linux","macos","openbsd","sunos","win32","windows"],"dist":{"shasum":"6c716c62b4af97647524975011f0430ff978add0","tarball":"https://registry.npmjs.org/@stdlib/stats-strided-meanpn/-/stats-strided-meanpn-0.1.0.tgz","fileCount":15,"integrity":"sha512-FC3qBHdd+yLIRYDWiTeYlRiF0VWa8dRAN22AMNf95Bdr5MHK6lyY4Q0J8mI2bHKHYIlCUwm0uM0k0bnRqKk5Lw==","signatures":[{"sig":"MEUCIQCQwiB6OvPHp0DR7P5xUEz+M8VsG9QcOOLDTLrRi9tIcAIgBkq28PWsE9mEVutJjuTisW3nc67O6JR6fPjrVHW7H0g=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52897},"main":"./lib","types":"./docs/types","engines":{"npm":">2.7.0","node":">=0.10.0"},"funding":{"url":"https://opencollective.com/stdlib","type":"opencollective"},"gitHead":"d660cabc2799c7f43cda85b7a4ff65e0995a9a1e","scripts":{},"_npmUser":{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},"repository":{"url":"git://github.com/stdlib-js/stats-strided-meanpn.git","type":"git"},"_npmVersion":"10.8.2","description":"Calculate the arithmetic mean of a strided array using a two-pass error correction algorithm.","directories":{"doc":"./docs","lib":"./lib","dist":"./dist"},"_nodeVersion":"20.20.0","dependencies":{"@stdlib/blas-ext-base-gsumpw":"^0.2.2","@stdlib/blas-ext-base-gapxsumpw":"^0.2.2","@stdlib/strided-base-stride2offset":"^0.1.0","@stdlib/array-base-arraylike2object":"^0.2.1","@stdlib/utils-define-nonenumerable-read-only-property":"^0.2.2"},"_hasShrinkwrap":false,"devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/stats-strided-meanpn_0.1.0_1769825932555_0.9435208691655195","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@stdlib/stats-strided-meanpn","version":"0.1.1","description":"Calculate the arithmetic mean of a strided array using a two-pass error correction algorithm.","license":"Apache-2.0","author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"main":"./lib","directories":{"doc":"./docs","lib":"./lib","dist":"./dist"},"types":"./docs/types","scripts":{},"homepage":"https://stdlib.io","repository":{"type":"git","url":"git://github.com/stdlib-js/stats-strided-meanpn.git"},"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"dependencies":{"@stdlib/array-base-arraylike2object":"^0.2.2","@stdlib/blas-ext-base-gapxsumpw":"^0.3.0","@stdlib/blas-ext-base-gsumpw":"^0.3.0","@stdlib/strided-base-stride2offset":"^0.1.1","@stdlib/utils-define-nonenumerable-read-only-property":"^0.2.3"},"devDependencies":{},"engines":{"node":">=0.10.0","npm":">2.7.0"},"os":["aix","darwin","freebsd","linux","macos","openbsd","sunos","win32","windows"],"keywords":["stdlib","stdmath","statistics","stats","mathematics","math","average","avg","mean","arithmetic mean","central tendency","strided","strided array","array"],"funding":{"type":"opencollective","url":"https://opencollective.com/stdlib"},"_id":"@stdlib/stats-strided-meanpn@0.1.1","gitHead":"65ac870bcc9363ee25cdde72514d9e0783b5395e","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Mu6bByEITlud9K/nrO7ICA0o5K+CP09GhWJoXS8BJWi2qmw/h/3O3RzBKkinKkUhoW9LVNSI+wmng4fU+rsXOQ==","shasum":"8a1bcb18c89dfebf74b0b9d52a09ee674a2c8779","tarball":"https://registry.npmjs.org/@stdlib/stats-strided-meanpn/-/stats-strided-meanpn-0.1.1.tgz","fileCount":15,"unpackedSize":52897,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCGAXwDErM1AYO4/ceefLCK/kQ85AZS4cot603QRcc3RgIhANPXvcggUAtVAygPPLtDpyIZQh12i2/qx4nL0iWmXJWe"}]},"_npmUser":{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},"maintainers":[{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/stats-strided-meanpn_0.1.1_1770579290756_0.8812353918558005"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-31T02:18:52.487Z","modified":"2026-02-08T19:34:51.034Z","0.1.0":"2026-01-31T02:18:52.701Z","0.1.1":"2026-02-08T19:34:50.889Z"},"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"license":"Apache-2.0","homepage":"https://stdlib.io","keywords":["stdlib","stdmath","statistics","stats","mathematics","math","average","avg","mean","arithmetic mean","central tendency","strided","strided array","array"],"repository":{"type":"git","url":"git://github.com/stdlib-js/stats-strided-meanpn.git"},"description":"Calculate the arithmetic mean of a strided array using a two-pass error correction algorithm.","contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"maintainers":[{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"}],"readme":"<!--\n\n@license Apache-2.0\n\nCopyright (c) 2025 The Stdlib Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n-->\n\n\n<details>\n  <summary>\n    About stdlib...\n  </summary>\n  <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>\n  <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>\n  <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>\n  <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>\n</details>\n\n# meanpn\n\n[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->\n\n> Calculate the [arithmetic mean][arithmetic-mean] of a strided array using a two-pass error correction algorithm.\n\n<section class=\"intro\">\n\nThe [arithmetic mean][arithmetic-mean] is defined as\n\n<!-- <equation class=\"equation\" label=\"eq:arithmetic_mean\" align=\"center\" raw=\"\\mu = \\frac{1}{n} \\sum_{i=0}^{n-1} x_i\" alt=\"Equation for the arithmetic mean.\"> -->\n\n<div class=\"equation\" align=\"center\" data-raw-text=\"\\mu = \\frac{1}{n} \\sum_{i=0}^{n-1} x_i\" data-equation=\"eq:arithmetic_mean\">\n    <img src=\"https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@7158616c9399e313d462e91b1a5c0f82d090c372/lib/node_modules/@stdlib/stats/strided/meanpn/docs/img/equation_arithmetic_mean.svg\" alt=\"Equation for the arithmetic mean.\">\n    <br>\n</div>\n\n<!-- </equation> -->\n\n</section>\n\n<!-- /.intro -->\n\n<section class=\"installation\">\n\n## Installation\n\n```bash\nnpm install @stdlib/stats-strided-meanpn\n```\n\n</section>\n\n<section class=\"usage\">\n\n## Usage\n\n```javascript\nvar meanpn = require( '@stdlib/stats-strided-meanpn' );\n```\n\n#### meanpn( N, x, strideX )\n\nComputes the [arithmetic mean][arithmetic-mean] of a strided array using a two-pass error correction algorithm.\n\n```javascript\nvar x = [ 1.0, -2.0, 2.0 ];\n\nvar v = meanpn( x.length, x, 1 );\n// returns ~0.3333\n```\n\nThe function has the following parameters:\n\n-   **N**: number of indexed elements.\n-   **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].\n-   **strideX**: stride length for `x`.\n\nThe `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 the input array\n\n```javascript\nvar x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ];\nvar v = meanpn( 4, x, 2 );\n// returns 1.25\n```\n\nNote that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.\n\n<!-- eslint-disable stdlib/capitalized-comments -->\n\n```javascript\nvar Float64Array = require( '@stdlib/array-float64' );\n\nvar x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );\nvar x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element\n\nvar v = meanpn( 4, x1, 2 );\n// returns 1.25\n```\n\n#### meanpn.ndarray( N, x, strideX, offsetX )\n\nComputes the [arithmetic mean][arithmetic-mean] of a strided array using a two-pass error correction algorithm and alternative indexing semantics.\n\n```javascript\nvar x = [ 1.0, -2.0, 2.0 ];\n\nvar v = meanpn.ndarray( x.length, x, 1, 0 );\n// returns ~0.33333\n```\n\nThe function has the following additional parameters:\n\n-   **offsetX**: starting index for `x`.\n\nWhile [`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 the strided array starting from the second element\n\n```javascript\nvar x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];\n\nvar v = meanpn.ndarray( 4, x, 2, 1 );\n// returns 1.25\n```\n\n</section>\n\n<!-- /.usage -->\n\n<section class=\"notes\">\n\n## Notes\n\n-   If `N <= 0`, both functions return `NaN`.\n-   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]).\n-   Depending on the environment, the typed versions ([`dmeanpn`][@stdlib/stats/strided/dmeanpn], [`smeanpn`][@stdlib/stats/strided/smeanpn], etc.) are likely to be significantly more performant.\n\n</section>\n\n<!-- /.notes -->\n\n<section class=\"examples\">\n\n## Examples\n\n<!-- eslint no-undef: \"error\" -->\n\n```javascript\nvar discreteUniform = require( '@stdlib/random-array-discrete-uniform' );\nvar meanpn = require( '@stdlib/stats-strided-meanpn' );\n\nvar x = discreteUniform( 10, -50, 50, {\n    'dtype': 'float64'\n});\nconsole.log( x );\n\nvar v = meanpn( x.length, x, 1 );\nconsole.log( v );\n```\n\n</section>\n\n<!-- /.examples -->\n\n* * *\n\n<section class=\"references\">\n\n## References\n\n-   Neely, Peter M. 1966. \"Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients.\" _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958][@neely:1966a].\n-   Schubert, Erich, and Michael Gertz. 2018. \"Numerically Stable Parallel Computation of (Co-)Variance.\" In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036][@schubert:2018a].\n\n</section>\n\n<!-- /.references -->\n\n<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->\n\n<section class=\"related\">\n\n* * *\n\n## See Also\n\n-   <span class=\"package-name\">[`@stdlib/stats-strided/dmeanpn`][@stdlib/stats/strided/dmeanpn]</span><span class=\"delimiter\">: </span><span class=\"description\">calculate the arithmetic mean of a double-precision floating-point strided array using a two-pass error correction algorithm.</span>\n-   <span class=\"package-name\">[`@stdlib/stats-strided/mean`][@stdlib/stats/strided/mean]</span><span class=\"delimiter\">: </span><span class=\"description\">calculate the arithmetic mean of a strided array.</span>\n-   <span class=\"package-name\">[`@stdlib/stats-strided/nanmeanpn`][@stdlib/stats/strided/nanmeanpn]</span><span class=\"delimiter\">: </span><span class=\"description\">calculate the arithmetic mean of a strided array, ignoring NaN values and using a two-pass error correction algorithm.</span>\n-   <span class=\"package-name\">[`@stdlib/stats-strided/smeanpn`][@stdlib/stats/strided/smeanpn]</span><span class=\"delimiter\">: </span><span class=\"description\">calculate the arithmetic mean of a single-precision floating-point strided array using a two-pass error correction algorithm.</span>\n\n</section>\n\n<!-- /.related -->\n\n<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->\n\n\n<section class=\"main-repo\" >\n\n* * *\n\n## Notice\n\nThis 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.\n\nFor 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].\n\n#### Community\n\n[![Chat][chat-image]][chat-url]\n\n---\n\n## License\n\nSee [LICENSE][stdlib-license].\n\n\n## Copyright\n\nCopyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].\n\n</section>\n\n<!-- /.stdlib -->\n\n<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->\n\n<section class=\"links\">\n\n[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-strided-meanpn.svg\n[npm-url]: https://npmjs.org/package/@stdlib/stats-strided-meanpn\n\n[test-image]: https://github.com/stdlib-js/stats-strided-meanpn/actions/workflows/test.yml/badge.svg?branch=v0.1.1\n[test-url]: https://github.com/stdlib-js/stats-strided-meanpn/actions/workflows/test.yml?query=branch:v0.1.1\n\n[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-strided-meanpn/main.svg\n[coverage-url]: https://codecov.io/github/stdlib-js/stats-strided-meanpn?branch=main\n\n<!--\n\n[dependencies-image]: https://img.shields.io/david/stdlib-js/stats-strided-meanpn.svg\n[dependencies-url]: https://david-dm.org/stdlib-js/stats-strided-meanpn/main\n\n-->\n\n[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg\n[chat-url]: https://stdlib.zulipchat.com\n\n[stdlib]: https://github.com/stdlib-js/stdlib\n\n[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors\n\n[umd]: https://github.com/umdjs/umd\n[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules\n\n[deno-url]: https://github.com/stdlib-js/stats-strided-meanpn/tree/deno\n[deno-readme]: https://github.com/stdlib-js/stats-strided-meanpn/blob/deno/README.md\n[umd-url]: https://github.com/stdlib-js/stats-strided-meanpn/tree/umd\n[umd-readme]: https://github.com/stdlib-js/stats-strided-meanpn/blob/umd/README.md\n[esm-url]: https://github.com/stdlib-js/stats-strided-meanpn/tree/esm\n[esm-readme]: https://github.com/stdlib-js/stats-strided-meanpn/blob/esm/README.md\n[branches-url]: https://github.com/stdlib-js/stats-strided-meanpn/blob/main/branches.md\n\n[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats-strided-meanpn/main/LICENSE\n\n[arithmetic-mean]: https://en.wikipedia.org/wiki/Arithmetic_mean\n\n[mdn-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\n\n[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray\n\n[@stdlib/array/base/accessor]: https://www.npmjs.com/package/@stdlib/array-base-accessor\n\n[@neely:1966a]: https://doi.org/10.1145/365719.365958\n\n[@schubert:2018a]: https://doi.org/10.1145/3221269.3223036\n\n<!-- <related-links> -->\n\n[@stdlib/stats/strided/dmeanpn]: https://www.npmjs.com/package/@stdlib/stats-strided-dmeanpn\n\n[@stdlib/stats/strided/mean]: https://www.npmjs.com/package/@stdlib/stats-strided-mean\n\n[@stdlib/stats/strided/nanmeanpn]: https://www.npmjs.com/package/@stdlib/stats-strided-nanmeanpn\n\n[@stdlib/stats/strided/smeanpn]: https://www.npmjs.com/package/@stdlib/stats-strided-smeanpn\n\n<!-- </related-links> -->\n\n</section>\n\n<!-- /.links -->\n","readmeFilename":"README.md"}