Comments (3)
here's what I wrote for my use case:
function findShiftedVariance(data){
if(data.length === 0){
throw new Error('Calculating variance of empty array')
}
var n;
var K;
var variance;
var sum;
var sumSqr;
K = data[0];
sum = 0;
sumSqr = 0;
for(n=0; n<data.length; n++){
var x = data[n];
sum = sum + (x - K);
sumSqr = sumSqr + ((x - K) * (x - K));
}
variance = (sumSqr - ( (sum*sum)/n ) ) / n;
return variance;
}
from simple-statistics.
hmm re-reading I note that I am dividing by n
in the last step because I have a complete data set; but if the data set is a sample of a larger data set you should divide by n-1
. how annoying :D
from simple-statistics.
Happy to accept a PR implementing this feature, but reading more about these algorithms doesn't uncover any that are sufficiently canonical.
from simple-statistics.
Related Issues (20)
- Error in linearRegresson HOT 2
- Docs link is broken
- ckmeans is not O(kn log(n))? HOT 1
- Do we have "Coefficient of Variation" function ? HOT 3
- Exports section of the package.json may need to be updated HOT 4
- cdnjs missing simple-statistics > 2.0.0-beta2 HOT 2
- Is there a way to efficiently calculate Skewness and Kurtosis of data having value with repetitions ? HOT 1
- What would the equivalent of NORM.DIST be? HOT 3
- datapoint labels HOT 2
- mean() evaluates nulls as zeros in calculation HOT 2
- Make simple-statistics available as a deno module? HOT 2
- Explicit type-checking HOT 2
- Bring back Jenks HOT 2
- add missing TypeScript typing for sampleRankCorrelation HOT 1
- coefficientOfVariation
- Unexpected results for multiple quantiles HOT 1
- document the revived `ss.jenks`?
- PerceptronModel Typing
- why is a math lib returning strings? HOT 7
- Linear Regression with time series data? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple-statistics.