Socket
Socket
Sign inDemoInstall

jstat

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jstat - npm Package Compare versions

Comparing version 1.8.0 to 1.8.1

test/test/anovafscore.js

4

doc/md/vector.md

@@ -806,7 +806,9 @@ ## Vector Functionality

**percentile( dataArray, k )**
**percentile( dataArray, k, [exclusive] )**
Returns the k-th percentile of values in the `dataArray` range, where k is in the range 0..1, exclusive.
Passing true for the exclusive parameter excludes both endpoints of the range.
jStat.percentile([1, 2, 3, 4], 0.3) === 1.9;
jStat.percentile([1, 2, 3, 4], 0.3, true) === 1.5;

@@ -813,0 +815,0 @@ ### percentileOfScore()

{
"name": "jstat",
"version": "1.8.0",
"version": "1.8.1",
"description": "Statistical Library for JavaScript",

@@ -5,0 +5,0 @@ "homepage": "http://github.com/jstat/jstat",

@@ -29,3 +29,3 @@ [jStat](http://www.jstat.org/) - JavaScript Statistical Library

CDN
CDN [![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/jstat/badge?style=rounded)](https://www.jsdelivr.com/package/npm/jstat)
---

@@ -32,0 +32,0 @@

@@ -404,2 +404,3 @@ var jStat = (function(Math, undefined) {

var rl = [];
var i;
step = step || 1;

@@ -406,0 +407,0 @@ if (end === undefined) {

@@ -132,6 +132,2 @@ (function(jStat, Math) {

}
// 2 sample case
if (args.length === 2) {
return jStat.variance(args[0]) / jStat.variance(args[1]);
}
// Builds sample array

@@ -138,0 +134,0 @@ sample = new Array();

@@ -311,18 +311,16 @@ (function(jStat, Math) {

// Returns the k-th percentile of values in a range, where k is in the
// range 0..1, exclusive.
jStat.percentile = function percentile(arr, k) {
// Return the k-th percentile of values in a range, where k is in the range 0..1, inclusive.
// Passing true for the exclusive parameter excludes both endpoints of the range.
jStat.percentile = function percentile(arr, k, exclusive) {
var _arr = arr.slice().sort(ascNum);
var realIndex = k * (_arr.length - 1);
var realIndex = k * (_arr.length + (exclusive ? 1 : -1)) + (exclusive ? 0 : 1);
var index = parseInt(realIndex);
var frac = realIndex - index;
if (index + 1 < _arr.length) {
return _arr[index] * (1 - frac) + _arr[index + 1] * frac;
return _arr[index - 1] + frac * (_arr[index] - _arr[index - 1]);
} else {
return _arr[index];
return _arr[index - 1];
}
}
// The percentile rank of score in a given array. Returns the percentage

@@ -329,0 +327,0 @@ // of all values in the input array that are less than (kind='strict') or

@@ -16,4 +16,25 @@ var vows = require('vows');

},
'30th percentile of the list in the range with exclusive flag true': function(jStat) {
assert.deepEqual(jStat.percentile([1, 2, 3, 4], 0.3, true), 1.5);
},
'30th percentile of the list in the range, unsorted': function(jStat) {
assert.deepEqual(jStat.percentile([3, 1, 4, 2], 0.3), 1.9);
},
'40th percentile of the list in the range with exclusive flag false': function(jStat) {
assert.epsilon(0.0000001, jStat.percentile([15, 20, 35, 40, 50], 0.4, false), 29);
},
'40th percentile of the list in the range with exclusive flag true': function(jStat) {
assert.epsilon(0.0000001, jStat.percentile([15, 20, 35, 40, 50], 0.4, true), 26);
},
'10th percentile of the list in the range with exclusive flag false': function(jStat) {
assert.epsilon(0.0000001, jStat.percentile([15, 20, 35, 40, 50], 0.1, false), 17);
},
'10th percentile of the list in the range with exclusive flag true': function(jStat) {
assert(isNaN(jStat.percentile([15, 20, 35, 40, 50], 0.1, true)));
},
'100th percentile of the list in the range with exclusive flag false': function(jStat) {
assert.epsilon(0.0000001, jStat.percentile([15, 20, 35, 40, 50], 1, false), 50);
},
'100th percentile of the list in the range with exclusive flag true': function(jStat) {
assert(isNaN(jStat.percentile([15, 20, 35, 40, 50], 1, true)));
}

@@ -20,0 +41,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc