This documentation is for WSO2 Complex Event Processor 4.0.0. View documentation for the latest release.
WSO2 Complex Event Processor is succeeded by WSO2 Stream Processor. To view the latest documentation for WSO2 SP, see WSO2 Stream Processor Documentation.

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

Siddhi enables users to forecast future events using linear regression on real time, data streams. The forecast function takes in a Y dependent event stream (Y), an X independent event stream (X) and a user specified next X value, and returns the forecast Y value based on the regression equation that fits of the historical data received.

Input Parameters





Calculation Interval


The frequency of regression calculation.

Default value: 1 (i.e. at every event)

Batch Size


The maximum number of events used for a regression calculation

Default value: 1,000,000,000 events

Confidence Interval


Confidence Interval to be used for regression calculation

Default value: 0.95

Next X Value


Value to be used to forecast the Y value. This can be a constant, or an expression (eg:- x+5)

Y Stream


Data stream of the dependent variable

X Stream


Data stream of the independent variable


Output Parameters




Forecast Y


Forecast Y value based on next X and regression equation.

Standard Error


Standard Error of the Regression Equation

β coefficients

beta0, beta1

β coefficients of the simple linear regression

Input Stream Data

Name given in the input stream

All items sent in the input stream



The following query submits a calculation interval (every 10 events), a batch size (100,000 evetns) a confidence interval (0.95) a an expression to be used as the next X value (X+2) a dependent input stream (Y) and 3 an independent input streams (X1, X2, X3stream (X) that will be used to perform linear regression between Y and all X streams, and compute the forecast Y value based on the next X value given by the user.

from StockExchangeStream#transform.timeseries:forecast(X+5, Y, X)