Skip to content
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

Added RandPoissonFlow and RandBinomialFlow #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions js/EquationEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ function EquationWindow(config) {
["Lognormal Distribution", "RandLognormal(##Mean$$, ##Standard Deviation$$)", "Generates a log-normally distributed random number with a mean and a standard deviation."],
["Binary Distribution", "RandBoolean(##Probability$$)", "Returns 1 with the specified probability, otherwise 0. The probability is optional and defaults to 0.5: a coin flip.", ["RandBoolean(0.1)", "False"]],
["Binomial Distribution", "RandBinomial(##Count$$, ##Probability$$)", "Generates a binomially distributed random number. The number of successes in Count random events each with Probability of success."],
["Binomial Distribution Flow", "RandBinomialFlow(##Count$$, ##Probability$$)", "Generates a binomially distribution adapted to simulation Timestep."],
["Negative Binomial", "RandNegativeBinomial(##Successes$$, ##Probability$$)", "Generates a negative binomially distributed random number. The number of random events each with Probability of success required to generate the specified Successes."],
["Poisson Distribution", "RandPoisson(##Lambda$$)", "Generates a Poisson distributed random number."],
["Poisson Distribution Flow", "RandPoissonFlow(##Lambda$$)", "Generates a Poisson distribution adapted to simulation Timestep."],
["Triangular Distribution", "RandTriangular(##Minimum$$, ##Maximum$$, ##Peak$$)", "Generates a triangularly distributed random number."],
["Exponential Distribution", "RandExp(##Lambda$$)", "Generates an exponentially distributed random number with the specified rate parameter."],
["Gamma Distribution", "RandGamma(##Alpha$$, ##Beta$$)", "Generates a Gamma distributed random number."],
Expand Down
8 changes: 8 additions & 0 deletions js/SimulationEngine/calc/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,20 @@ defineFunction("RandBinomial", {params: [{name:"Count", noUnits:true, noVector:t
defineFunction("RandNegativeBinomial", {params: [{name:"Successes", noUnits:true, noVector:true}, {name:"Probability", noUnits:true, noVector:true}]}, function(x){
return new Material(RandNegativeBinomial(x[0].toNum().value, x[1].toNum().value));
});
defineFunction("RandBinomialFlow", {params: [{name:"Count", noUnits:true, noVector:true}, {name:"Probability", noUnits:true, noVector:true}]}, function(x){
var dt=simulate.timeStep.toNum().value;
return new Material(RandBinomial(x[0].toNum().value, dt*x[1].toNum().value)/dt);
});
defineFunction("RandGamma", {params:[{name:"Alpha", noUnits:true, noVector:true}, {name:"Beta", noUnits:true, noVector:true}]}, function(x){
return new Material(RandGamma(x[0].toNum().value, x[1].toNum().value));
});
defineFunction("RandPoisson", {params:[{name:"Rate", noUnits:true, noVector:true}]}, function(x){
return new Material(RandPoisson(x[0].toNum().value));
});
defineFunction("RandPoissonFlow", {params:[{name:"Rate", noUnits:true, noVector:true}]}, function(x){
var dt=simulate.timeStep.toNum().value;
return new Material(RandPoisson(dt*x[0].toNum().value)/dt);
});
defineFunction("RandTriangular", {params:[{name:"Minimum", noUnits:true, noVector:true}, {name:"Maximum", noUnits:true, noVector:true}, {name:"Peak", noUnits:true, noVector:true}]}, function(x){
return new Material(RandTriangular(x[0].toNum().value, x[1].toNum().value, x[2].toNum().value));
});
Expand Down