-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More statistical functions added to stats.js (2) #4
Conversation
Geometric Distribution (PDF) Binomial Distribution Binomial Coefficient Log Series Distribution Lognormal Distribution (PDF) Gumbel Distribution Uniform Distribution Linear Moving Average
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General
Keep standard structure of description and examples as follows:
/**
Description of the method
@method functionName
...
@example
const data = [someData]
const params = {someParams}
hydro.analyze.stats.fuctionName(//...)
*/
Log Series
Log series distributions is incorrect. See attached:
logSeriesDist({ params, args, data }) {
//...
const pmf = -Math.log(1 - probSuccess) * Math.pow(probSuccess, trials) / trials;
return pmf;
}
Gumbel
Move the x
to args
, just as in the rest of the distributions.
Linear moving average
- This is the implementation of a simple moving average. Let's rename this function as such.
- Move the data to the
data
parameter instead ofargs
. - The
@example
tag should be as other implementations. e.g.hydro.analyze.stats.simpleMovingAverage({params: {windowSize}, data}})
DescriptionThe following functions have been added into stats.js: Type of change
How Has This Been Tested?Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist:
The following new functions have been added into stats.js: <style type="text/css"></style>Homogenous Poisson ProcessNon-Homogenous Poisson Process Type of change
How Has This Been Tested?Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General
- Keep consistency on the comments. Example:
/**
* This is a description of the function, thorough or simple depending on the function.
* @method nameOfFunction
* ...
*/
Multinomial Distribution
There is an error with the distribution. Frequencies should account for repetition of numbers, the function copies the same numbers as samples.
Consider the following changes:
static multinomialDistribution({ params, args, data }) {
//...
for (let i = 0; i < n; i++) {
const sample = [];
const frequency = Array(numCategories).fill(0);//delete this
//...
frequencies.push(this.frequency({data: sample}));//there is already a function for calculating frequencies
}
return { samples, frequencies };
}
Expo Moving Average
Move the data from args
to data
field and the alpha
variable to params
. Change the internal code accordingly.
/**
*const data= [1,2,3,4,5]
*const params={alpha: 0.5}
*hydro.analyze.stats.exponentialMovingAverage({params, data});
*/
Poisson Process
The implemented functions can be joined together passing a flag in the params
object to switch the implementation type, defaulting to homogeneous
if type
is not passed.
Example implementation:
static poissonProcess({ params, args }) {
const { type = 'homogeneous', T } = params;
const { lambda, rateFunction } = args;
const events = [];
let t = 0;
while (t < T) {
const rand = Math.random();
const interTime = (type === 'homogeneous' ? -1 / lambda : -1 / rateFunction(t)) * Math.log(1 - rand);
t += interTime;
if (t < T) {
if (type === 'homogeneous' || Math.random() <= rateFunction(t) / rateFunction(T)) {
events.push(t);
}
}
}
return events;
}
Documentation would look something like this:
/**
*Poisson process (more description here)
*...
*@param {Object} params - contains type: homogeneous or non homogeneous. Defaults to homogenous.
*@example
*Two examples, one for each test case
*/
Boxplot Distribution
Remove data
parameter from the example
as it isn't used.
MSE
Move the datasets into the data
parameter.
New functions on stats: Geometric Distribution (PDF), Binomial Distribution, Binomial Coefficient, Log Series Distribution, Lognormal Distribution (PDF), Gumbel Distribution, Uniform Distribution, Simple Moving Average |
Description
The following functions have been added into stats.js:
Geometric Distribution (PDF)
Binomial Distribution
Binomial Coefficient
Log Series Distribution
Lognormal Distribution (PDF)
Gumbel Distribution
Uniform Distribution
Linear Moving Average
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: