Never Perfectly Managed

    statler
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    npm

    statler

    Yet another statistics helper library

    Usage

    Histogram

    import { Histogram } from 'statler';
     
    const histogram = new Histogram(
      { multiple: 50 },
      [151, 98, 159]
    );
     
    console.log(histogram.toJSON());
    // [
    //   [ 100, 1 ],
    //   [ 150, 2 ]
    // ]

    Alternatively, you can call toCSV() (this is handy to write to file, open in Excel, and generate a graph quickly)

    const histogram = new Histogram(
      { multiple: 50 },
      [151, 98, 159]
    );
     
    console.log(histogram.toCSV());
    // bucket,count
    // 100,1
    // 150,2

    You can keep adding data to an existing histogram

    const histogram = new Histogram({
      multiple: 50,
    }, [151]);
    histogram.push([98, 159]);
     
    console.log(histogram.toJSON());
    // [
    //   [ 100, 1 ],
    //   [ 150, 2 ]
    // ]

    You can have multiple series (or categories)

    const histogram = new Histogram(
      { multiple: 50 },
      {
        cat1: [102, 149, 53],
        cat2: [98, 151, 159]
      }
    );
     
    console.log(histogram.toJSON());
    // [
    //   [ 50, { cat1: 1, cat2: 0 } ],
    //   [ 100, { cat1: 1, cat2: 1 } ],
    //   [ 150, { cat1: 1, cat2: 2 } ]
    // ]

    Running tests

    Run tests with npm test

    License

    MIT

    Keywords

    none

    Install

    npm i statler

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    17.7 kB

    Total Files

    11

    Last publish

    Collaborators

    • cowchimp