LOGEST
function LOGEST(arg1: ApiRange = null, arg2: ApiRange = null, arg3: boolean = null, arg4: boolean = null): number
Description
Returns statistics that describe an exponential curve matching known data points.
Parameters
The set of y-values from the y = b*m^x equation.
An optional set of x-values from the y = b*m^x equation.
- arg3
boolean
null A logical value: the constant b is calculated normally if this parameter is set to true or omitted, and b is set equal to 1 if the parameter is false.
- arg4
boolean
null A logical value: return additional regression statistics if this parameter is set to true, and return m-coefficients and the constant b if the parameter is false or omitted.
Returns
number
Try It
const oWorksheet = Api.GetActiveSheet();
//configure function parameters
var yValues = [1500, 1230, 1700, 1000, 980, 1470, 1560, 1640, 1420, 1100];
var xValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var constant = true;
var stats = false;
//set values in cells
for (var i = 0; i < yValues.length; i++) {
oWorksheet.GetRange("A" + (i + 1)).SetValue(yValues[i]);
}
for (var i = 0; i < xValues.length; i++) {
oWorksheet.GetRange("B" + (i + 1)).SetValue(xValues[i]);
}
//get x and y ranges
var yRange = oWorksheet.GetRange("A1:A10");
var xRange = oWorksheet.GetRange("B1:B10");
var oFunction = Api.GetWorksheetFunction();
//invoke LOGEST method
var ans = oFunction.LOGEST(yRange, xRange, constant, stats);
//print answer
oWorksheet.GetRange("D1").SetValue(ans);