curvefit

Runs a linear regression analysis for the input using the Least Mean Square (LMS).

Syntax

curvefit [degree=INT] INDEPENDENT_FIELD, DEPENDENT_FIELD
Required Parameters
INDEPENDENT_FIELD
Field as the independent variable. The value of the independent variable must be numeric.
DEPENDENT_FIELD
Field as the dependent variable. The value of the dependent variable must be numeric.
Optional Parameters
degree=INT
Degree of the polynomial function that approximates the input value (default: 3).

Description

This runs a linear regression analysis using the least mean square for up to 10,000 input record values. This assigns the independent variable field value to the _x field and the predicted value to the _p field. It ignores records after 10,000.

Usage

Approximate the CPU usage rate for the past 1 hour with a tenth polynomial function.

table duration=1h sys_cpu_logs 
| eval x = datediff(dateadd(now(), "hour", -1), _time, "sec") 
| eval total = kernel + user 
| curvefit degree=10 x, total