Skip to content

Instantly share code, notes, and snippets.

@jaimelr
Created May 11, 2023 21:25
Show Gist options
  • Save jaimelr/643808474de618593111aac9c27956c5 to your computer and use it in GitHub Desktop.
Save jaimelr/643808474de618593111aac9c27956c5 to your computer and use it in GitHub Desktop.

Instructions

  1. Clone the repository to your local development environment https://github.com/simple-statistics/simple-statistics
  2. git checkout to tag v7.7.2

Description of the bug

The mean() function does not raise an error for null values in sample, nor is there a note in the documentation specifying this.

Here's an example of where I realized this:

  const ss = require("simple-statistics");
  
  var x = [null, 30, null];
  console.log(ss.mean(x));
  
  # which returns: 10

Expected behavior

When passing in NaN, nulls, strings, or undefined values to the function, the result should be NaN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment