stats-array-nanmskrange
Effortlessly compute statistical ranges in arrays with stats-array-nanmskrange. Ideal for numerical tasks in JavaScript and Node.js. ππ
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
βCITATION.cff file
Found CITATION.cff file -
βcodemeta.json file
Found codemeta.json file -
β.zenodo.json file
Found .zenodo.json file -
βDOI references
-
βAcademic publication links
-
βAcademic email domains
-
βInstitutional organization owner
-
βJOSS paper metadata
-
βScientific vocabulary similarity
Low similarity (15.1%) to scientific vocabulary
Keywords
Repository
Effortlessly compute statistical ranges in arrays with stats-array-nanmskrange. Ideal for numerical tasks in JavaScript and Node.js. ππ
Basic Info
- Host: GitHub
- Owner: KITcn17
- License: apache-2.0
- Language: JavaScript
- Default Branch: main
- Size: 50.8 KB
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 1
Topics
Metadata Files
README.md
Calculate Array Range with Masking for NaN Values in JavaScript
Overview
The stats-array-nanmskrange repository provides a simple and effective way to calculate the range of an array while ignoring NaN values based on a specified mask. This tool is useful in statistical analysis, data science, and any situation where clean data is essential for accurate calculations.
Table of Contents
Installation
To install the package, you can use npm. Run the following command in your terminal:
bash
npm install stats-array-nanmskrange
For the latest releases, visit Releases to download and execute the necessary files.
Usage
To use the library, first import it into your JavaScript file:
javascript
const { maskedRange } = require('stats-array-nanmskrange');
Then, you can call the maskedRange function with your array and mask:
```javascript const array = [1, 2, NaN, 4, 5]; const mask = [true, true, false, true, true];
const range = maskedRange(array, mask); console.log(range); // Outputs the range while ignoring NaN ```
Functionality
The main function, maskedRange, calculates the range of an array based on a mask. Hereβs how it works:
- Input Array: This is the array from which you want to calculate the range.
- Mask: A boolean array that indicates which elements to include in the calculation. Elements corresponding to
truein the mask are included, while those corresponding tofalseare ignored. - NaN Handling: The function automatically ignores any
NaNvalues in the input array.
Key Features
- Efficiently calculates the maximum and minimum values.
- Ignores
NaNvalues to ensure accurate results. - Simple API that integrates easily into existing projects.
API Reference
maskedRange(array, mask)
Parameters:
array(Array): The input array of numbers.mask(Array): A boolean array indicating which elements to consider.
Returns: An object containing the minimum and maximum values, and the calculated range.
Example:
javascript
const result = maskedRange([1, 2, NaN, 4, 5], [true, true, false, true, true]);
console.log(result); // { min: 1, max: 5, range: 4 }
Examples
Here are some examples to demonstrate how to use the maskedRange function effectively.
Example 1: Basic Usage
```javascript const array = [3, NaN, 7, 2, 5]; const mask = [true, false, true, true, true];
const result = maskedRange(array, mask); console.log(result); // { min: 2, max: 7, range: 5 } ```
Example 2: All NaN Values
```javascript const array = [NaN, NaN, NaN]; const mask = [true, true, true];
const result = maskedRange(array, mask); console.log(result); // { min: NaN, max: NaN, range: NaN } ```
Example 3: Mixed Values
```javascript const array = [10, 20, NaN, 5, 15]; const mask = [true, true, false, true, false];
const result = maskedRange(array, mask); console.log(result); // { min: 5, max: 20, range: 15 } ```
Contributing
We welcome contributions to enhance the functionality of this library. If you want to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/YourFeature). - Open a Pull Request.
Code of Conduct
Please adhere to our Code of Conduct in all interactions within the community.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support
For support, please open an issue in the GitHub repository. We will address your concerns as soon as possible.
For the latest releases, visit Releases to download and execute the necessary files.
Topics
This repository covers various topics related to statistical analysis and array manipulation. Here are some relevant keywords:
- Array: Fundamental data structure for storing lists of items.
- Dispersion: Measure of how spread out the values are.
- Domain: The set of possible values for the input array.
- Extent: The range of values from minimum to maximum.
- Extremes: The highest and lowest values in the array.
- JavaScript: The programming language used for this library.
- Masked: Refers to the use of a mask to filter values.
- Math: Underlying principles of mathematics applied in this library.
- Maximum: The highest value in the selected range.
- Minimum: The lowest value in the selected range.
- Node.js: JavaScript runtime used for server-side applications.
- Range: The difference between the maximum and minimum values.
- Statistics: The science of collecting, analyzing, and interpreting data.
- Stdlib: Standard library that may provide additional mathematical functions.
Feel free to explore the repository, and make use of the tools provided to enhance your data analysis tasks.
Owner
- Login: KITcn17
- Kind: user
- Repositories: 2
- Profile: https://github.com/KITcn17
Citation (CITATION.cff)
cff-version: 1.2.0
title: stdlib
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- name: The Stdlib Authors
url: https://github.com/stdlib-js/stdlib/graphs/contributors
repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io
abstract: |
Standard library for JavaScript and Node.js.
keywords:
- JavaScript
- Node.js
- TypeScript
- standard library
- scientific computing
- numerical computing
- statistical computing
license: Apache-2.0 AND BSL-1.0
date-released: 2016
GitHub Events
Total
- Push event: 129
- Create event: 1
Last Year
- Push event: 129
- Create event: 1
Dependencies
- @stdlib/array-base-to-accessor-array ^0.2.2 development
- @stdlib/array-bool ^0.1.0 development
- @stdlib/array-complex128 ^0.3.0 development
- @stdlib/array-filled-by ^0.2.1 development
- @stdlib/bench-harness ^0.2.2 development
- @stdlib/math-base-assert-is-nan ^0.2.2 development
- @stdlib/math-base-assert-is-positive-zero ^0.2.2 development
- @stdlib/math-base-special-pow ^0.3.0 development
- @stdlib/random-base-bernoulli ^0.2.1 development
- @stdlib/random-base-uniform ^0.2.1 development
- istanbul ^0.4.1 development
- tap-min git+https://github.com/Planeshifter/tap-min.git development
- tape git+https://github.com/kgryte/tape.git#fix/globby development
- @stdlib/array-base-assert-contains ^0.2.2
- @stdlib/array-base-join ^0.1.1
- @stdlib/array-dtype ^0.3.0
- @stdlib/array-dtypes ^0.3.0
- @stdlib/assert-is-collection ^0.2.2
- @stdlib/error-tools-fmtprodmsg ^0.2.2
- @stdlib/stats-strided-nanmskrange github:stdlib-js/stats-strided-nanmskrange#main
- @stdlib/string-format ^0.2.2
- @stdlib/types ^0.4.3