NEGBINOMDIST
Returns the negative binomial distribution, the probability that there will be the specified number of failures before the last success, with the specified probability of a success.
Syntax
expression.NEGBINOMDIST(arg1, arg2, arg3);
expression
- A variable that represents a ApiWorksheetFunction class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
arg1 | Required | ApiRange | ApiName | number | The number of failures. | |
arg2 | Required | ApiRange | ApiName | number | The threshold number of successes. | |
arg3 | Required | ApiRange | ApiName | number | The probability of a success; a number between 0 and 1. |
Returns
number
Example
This example shows how to return the negative binomial distribution, the probability that there will be the specified number of failures before the last success, with the specified probability of a success.
- Code
- Result
// How to return the negative binomial distribution.
// Use a function to get the probability of the specified number of failures before the last success (negative binomial distribution).
const worksheet = Api.GetActiveSheet();
let valueArr = [6, 32, 0.7];
// Place the numbers in cells
for (let i = 0; i < valueArr.length; i++) {
worksheet.GetRange("A" + (i + 1)).SetValue(valueArr[i]);
}
//method params
let numberF = worksheet.GetRange("A1").GetValue();
let numberS = worksheet.GetRange("A2").GetValue();
let probabilityS = worksheet.GetRange("A3").GetValue();
let func = Api.GetWorksheetFunction();
let ans = func.NEGBINOMDIST(numberF, numberS, probabilityS);
worksheet.GetRange("C1").SetValue(ans);