Skip to content

lhui0005/stats-max

πŸ“Š Stats-Max: Compute Maximum Values in ndarrays

Welcome to the Stats-Max repository! This project helps you compute the maximum value along one or more dimensions of ndarrays. If you're working with numerical data in JavaScript, this tool will streamline your calculations and enhance your data analysis capabilities.

πŸš€ Table of Contents

πŸ“– Introduction

In data analysis, finding the maximum value is a common task. Whether you're analyzing statistical data or working with multidimensional arrays, having a reliable way to compute maximum values is essential. Stats-Max offers a simple yet powerful solution for this purpose.

This library is designed for use in JavaScript environments, including Node.js. It works with ndarrays, making it ideal for those who deal with large datasets and require efficient computations.

✨ Features

  • Easy to Use: Simple API for quick integration.
  • Multidimensional Support: Compute maximum values across one or more dimensions.
  • Fast Performance: Optimized for speed, even with large datasets.
  • Lightweight: Minimal dependencies to keep your project lean.
  • Flexible: Works seamlessly with existing JavaScript code.

πŸ“₯ Installation

To get started with Stats-Max, you can install it via npm. Run the following command in your terminal:

npm install stats-max

After installation, you can start using the library in your project. If you want to download the latest version, visit the Releases section.

πŸ› οΈ Usage

Using Stats-Max is straightforward. Here’s a quick example to demonstrate its functionality.

const { max } = require('stats-max');

// Create an ndarray
const data = [1, 2, 3, 4, 5];

// Compute the maximum value
const maxValue = max(data);
console.log(`The maximum value is: ${maxValue}`);

This code snippet computes the maximum value from a simple array. You can extend this to work with more complex ndarrays.

πŸ“š API Reference

max(data, [axis])

  • data: The input ndarray (array of numbers).
  • axis: (Optional) The dimension along which to compute the maximum. If not provided, it computes the maximum over the entire array.

Returns: The maximum value found in the specified dimension.

Example

const { max } = require('stats-max');

const data2D = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
];

// Compute maximum across rows
const maxInRows = max(data2D, 0);
console.log(maxInRows); // Output: [7, 8, 9]

// Compute maximum across columns
const maxInCols = max(data2D, 1);
console.log(maxInCols); // Output: [3, 6, 9]

πŸ“Š Examples

Example 1: Basic Maximum Calculation

const { max } = require('stats-max');

const singleArray = [10, 20, 30, 40];
console.log(max(singleArray)); // Output: 40

Example 2: Maximum in 2D Arrays

const { max } = require('stats-max');

const twoDArray = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
];

console.log(max(twoDArray, 0)); // Output: [7, 8, 9] (max of each column)
console.log(max(twoDArray, 1)); // Output: [3, 6, 9] (max of each row)

Example 3: Handling Large Datasets

For large datasets, performance is key. Stats-Max is optimized to handle large ndarrays efficiently. Here’s how you can use it:

const { max } = require('stats-max');

const largeData = Array.from({ length: 1000000 }, (_, i) => i);
console.log(max(largeData)); // Output: 999999

🀝 Contributing

We welcome contributions to Stats-Max! If you would like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them.
  4. Push to your branch.
  5. Open a pull request.

Please ensure your code follows our coding standards and includes appropriate tests.

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

πŸ“¬ Contact

For questions or feedback, feel free to reach out:

Thank you for checking out Stats-Max! We hope it helps you in your data analysis tasks. For more updates and releases, visit the Releases section.

Packages

No packages published

Contributors 2

  •  
  •