Simulator first commit

This commit is contained in:
2019-09-18 11:11:16 +03:00
commit 6e1686be67
5028 changed files with 985331 additions and 0 deletions

9
node_modules/stats-lite/LICENSE generated vendored Normal file
View File

@ -0,0 +1,9 @@
(The MIT License)
Copyright (c) Bryce B. Baril <bryce@ravenwall.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

140
node_modules/stats-lite/README.md generated vendored Normal file
View File

@ -0,0 +1,140 @@
stats-lite
=====
[![NPM](https://nodei.co/npm/stats-lite.png)](https://nodei.co/npm/stats-lite/)
A fairly light statistical package. Works with numeric arrays, and will automatically filter out non-numeric values and attempt to convert string numeric values.
## Install
```
npm install stats-lite --save
```
Example
---
[Live Demo using Browserify!](http://requirebin.com/embed?gist=brycebaril/9591291)
```javascript
var stats = require("stats-lite")
var dice = require("dice")
var rolls = []
for (var i = 0; i < 3000; i++) {
rolls.push(dice.sum(dice.roll("2d6")))
}
console.log("sum: %s", stats.sum(rolls))
console.log("mean: %s", stats.mean(rolls))
console.log("median: %s", stats.median(rolls))
console.log("mode: %s", stats.mode(rolls))
console.log("variance: %s", stats.variance(rolls))
console.log("standard deviation: %s", stats.stdev(rolls))
console.log("sample standard deviation: %s", stats.sampleStdev(rolls))
console.log("85th percentile: %s", stats.percentile(rolls, 0.85))
console.log("histogram:", stats.histogram(rolls, 10))
/* Your exact numbers may vary, but they should be pretty similar:
sum: 21041
mean: 7.0136666666666665
median: 7
mode: 7
variance: 5.8568132222220415
standard deviation: 2.4200853749861886
sample standard deviation: 2.4204888234135953
85th percentile: 10
histogram { values: [ 94, 163, 212, 357, 925, 406, 330, 264, 164, 85 ],
bins: 10,
binWidth: 1.05,
binLimits: [ 1.75, 12.25 ] }
*/
```
**Compatibility Notice**: Version 2.0.0+ of this library use features that require Node.js v4.0.0 and above
API
===
All of the exported functions take `vals` which is an array of numeric values. Non-numeric values will be removed, and string numbers will be converted to Numbers.
**NOTE**: This will impact some operations, e.g. `mean([null, 1, 2, 3])` will be calculated as `mean([1, 2, 3])`, (e.g. `6 / 3 = 2`, NOT `6 / 4 = 1.5`)
`numbers(vals)`
---
Accepts an array of values and returns an array consisting of only numeric values from the source array. Converts what it can and filters out anything else. e.g.
```js
numbers(["cat", 1, "22.9", 9])
// [1, 22.9, 9]
```
`sum(vals)`
---
[Sum](http://en.wikipedia.org/wiki/Summation) the values in the array.
`mean(vals)`
---
Calculate the [mean](http://en.wikipedia.org/wiki/Mean) average value of `vals`.
`median(vals)`
---
Calculate the [median](http://en.wikipedia.org/wiki/Median) average value of `vals`.
`mode(vals)`
---
Calculate the [mode](http://en.wikipedia.org/wiki/Mode_statistics) average value of `vals`.
If `vals` is multi-modal (contains multiple modes), `mode(vals)` will return a ES6 Set of the modes.
`variance(vals)`
---
Calculate the [variance](http://en.wikipedia.org/wiki/Variance) from the mean for a population.
`stdev(vals)`
---
Calculate the [standard deviation](http://en.wikipedia.org/wiki/Standard_deviation) of the values from the mean for a population.
`sampleVariance(vals)`
---
Calculate the [variance](http://en.wikipedia.org/wiki/Variance) from the mean for a sample.
`sampleStdev(vals)`
---
Calculate the [standard deviation](http://en.wikipedia.org/wiki/Standard_deviation) of the values from the mean for a sample.
`percentile(vals, ptile)`
---
Calculate the value representing the desired [percentile](http://en.wikipedia.org/wiki/Percentile) `(0 < ptile <= 1)`. Uses the Estimation method to interpolate non-member percentiles.
`histogram(vals[, bins])`
---
Build a histogram representing the distribution of the data in the provided number of `bins`. If `bins` is not set, it will choose one based on `Math.sqrt(vals.length)`. Data will look like:
```
histogram {
values: [ 86, 159, 253, 335, 907, 405, 339, 270, 146, 100 ],
bins: 10,
binWidth: 1.05,
binLimits: [ 1.75, 12.25 ]
}
```
Where `values` are the bins and the counts of the original values falling in that range. The ranges can be calculated from the `binWidth` and `binLimits`. For example, the first bin `values[0]` in this example is from `1.75 < value <= 2.8`. The third bin `values[2]` would be `1.75 + (1.05 * 2) < value <= 1.75 + (1.05 * 3)` or `3.85 < value <= 4.9`.
LICENSE
=======
MIT

74
node_modules/stats-lite/package.json generated vendored Normal file
View File

@ -0,0 +1,74 @@
{
"_from": "stats-lite@^2.1.0",
"_id": "stats-lite@2.2.0",
"_inBundle": false,
"_integrity": "sha512-/Kz55rgUIv2KP2MKphwYT/NCuSfAlbbMRv2ZWw7wyXayu230zdtzhxxuXXcvsc6EmmhS8bSJl3uS1wmMHFumbA==",
"_location": "/stats-lite",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "stats-lite@^2.1.0",
"name": "stats-lite",
"escapedName": "stats-lite",
"rawSpec": "^2.1.0",
"saveSpec": null,
"fetchSpec": "^2.1.0"
},
"_requiredBy": [
"/stats-incremental"
],
"_resolved": "https://registry.npmjs.org/stats-lite/-/stats-lite-2.2.0.tgz",
"_shasum": "278a5571fa1d2e8b1691295dccc0235282393bbf",
"_spec": "stats-lite@^2.1.0",
"_where": "/home/sergiu/linx-audio-simulator/node_modules/stats-incremental",
"author": {
"name": "Bryce B. Baril"
},
"bugs": {
"url": "https://github.com/brycebaril/node-stats-lite/issues"
},
"bundleDependencies": false,
"dependencies": {
"isnumber": "~1.0.0"
},
"deprecated": false,
"description": "A light statistical package that operates on numeric Arrays.",
"devDependencies": {
"dice": "0.0.2",
"tape": "~4.6.3"
},
"directories": {
"example": "examples",
"test": "test"
},
"engines": {
"node": ">=2.0.0"
},
"homepage": "https://github.com/brycebaril/node-stats-lite",
"keywords": [
"stats",
"statistics",
"numbers",
"math",
"sum",
"mean",
"average",
"mode",
"median",
"percentile",
"variance",
"deviation"
],
"license": "MIT",
"main": "stats.js",
"name": "stats-lite",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/brycebaril/node-stats-lite.git"
},
"scripts": {
"test": "node test/"
},
"version": "2.2.0"
}

210
node_modules/stats-lite/stats.js generated vendored Normal file
View File

@ -0,0 +1,210 @@
"use strict";
module.exports.numbers = numbers
module.exports.sum = sum
module.exports.mean = mean
module.exports.median = median
module.exports.mode = mode
module.exports.variance = populationVariance
module.exports.sampleVariance = sampleVariance
module.exports.populationVariance = populationVariance
module.exports.stdev = populationStdev
module.exports.sampleStdev = sampleStdev
module.exports.populationStdev = populationStdev
module.exports.percentile = percentile
module.exports.histogram = histogram
var isNumber = require("isnumber")
function numbers(vals) {
var nums = []
if (vals == null)
return nums
for (var i = 0; i < vals.length; i++) {
if (isNumber(vals[i]))
nums.push(+vals[i])
}
return nums
}
function nsort(vals) {
return vals.sort(function numericSort(a, b) { return a - b })
}
function sum(vals) {
vals = numbers(vals)
var total = 0
for (var i = 0; i < vals.length; i++) {
total += vals[i]
}
return total
}
function mean(vals) {
vals = numbers(vals)
if (vals.length === 0) return NaN
return (sum(vals) / vals.length)
}
function median(vals) {
vals = numbers(vals)
if (vals.length === 0) return NaN
var half = (vals.length / 2) | 0
vals = nsort(vals)
if (vals.length % 2) {
// Odd length, true middle element
return vals[half]
}
else {
// Even length, average middle two elements
return (vals[half-1] + vals[half]) / 2.0
}
}
// Returns the mode of a unimodal dataset
// If the dataset is multi-modal, returns a Set containing the modes
function mode(vals) {
vals = numbers(vals)
if (vals.length === 0) return NaN
var mode = NaN
var dist = {}
for (var i = 0; i < vals.length; i++) {
var value = vals[i]
var me = dist[value] || 0
me++
dist[value] = me
}
var rank = numbers(Object.keys(dist).sort(function sortMembers(a, b) { return dist[b] - dist[a] }))
mode = rank[0]
if (dist[rank[1]] == dist[mode]) {
// multi-modal
if (rank.length == vals.length) {
// all values are modes
return vals
}
var modes = new Set([mode])
var modeCount = dist[mode]
for (var i = 1; i < rank.length; i++) {
if (dist[rank[i]] == modeCount) {
modes.add(rank[i])
}
else {
break
}
}
return modes
}
return mode
}
// This helper finds the mean of all the values, then squares the difference
// from the mean for each value and returns the resulting array. This is the
// core of the varience functions - the difference being dividing by N or N-1.
function valuesMinusMeanSquared(vals) {
vals = numbers(vals)
var avg = mean(vals)
var diffs = []
for (var i = 0; i < vals.length; i++) {
diffs.push(Math.pow((vals[i] - avg), 2))
}
return diffs
}
// Population Variance = average squared deviation from mean
function populationVariance(vals) {
return mean(valuesMinusMeanSquared(vals))
}
// Sample Variance
function sampleVariance(vals) {
var diffs = valuesMinusMeanSquared(vals)
if (diffs.length <= 1) return NaN
return sum(diffs) / (diffs.length - 1)
}
// Population Standard Deviation = sqrt of population variance
function populationStdev(vals) {
return Math.sqrt(populationVariance(vals))
}
// Sample Standard Deviation = sqrt of sample variance
function sampleStdev(vals) {
return Math.sqrt(sampleVariance(vals))
}
function percentile(vals, ptile) {
vals = numbers(vals)
if (vals.length === 0 || ptile == null || ptile < 0) return NaN
// Fudge anything over 100 to 1.0
if (ptile > 1) ptile = 1
vals = nsort(vals)
var i = (vals.length * ptile) - 0.5
if ((i | 0) === i) return vals[i]
// interpolated percentile -- using Estimation method
var int_part = i | 0
var fract = i - int_part
return (1 - fract) * vals[int_part] + fract * vals[Math.min(int_part + 1, vals.length - 1)]
}
function histogram (vals, bins) {
if (vals == null) {
return null
}
vals = nsort(numbers(vals))
if (vals.length === 0) {
return null
}
if (bins == null) {
// pick bins by simple method: Math.sqrt(n)
bins = Math.sqrt(vals.length)
}
bins = Math.round(bins)
if (bins < 1) {
bins = 1
}
var min = vals[0]
var max = vals[vals.length - 1]
if (min === max) {
// fudge for non-variant data
min = min - 0.5
max = max + 0.5
}
var range = (max - min)
// make the bins slightly larger by expanding the range about 10%
// this helps with dumb floating point stuff
var binWidth = (range + (range * 0.05)) / bins
var midpoint = (min + max) / 2
// even bin count, midpoint makes an edge
var leftEdge = midpoint - (binWidth * Math.floor(bins / 2))
if (bins % 2 !== 0) {
// odd bin count, center middle bin on midpoint
var leftEdge = (midpoint - (binWidth / 2)) - (binWidth * Math.floor(bins / 2))
}
var hist = {
values: Array(bins).fill(0),
bins: bins,
binWidth: binWidth,
binLimits: [leftEdge, leftEdge + (binWidth * bins)]
}
var binIndex = 0
for (var i = 0; i < vals.length; i++) {
while (vals[i] > (((binIndex + 1) * binWidth) + leftEdge)) {
binIndex++
}
hist.values[binIndex]++
}
return hist
}