def linearRegression(requestContext, seriesList, startSourceAt=None,
                     endSourceAt=None):
    """
    Graphs the liner regression function by least squares method.

    Takes one metric or a wildcard seriesList, followed by a quoted string
    with the time to start the line and another quoted string with the time
    to end the line. The start and end times are inclusive (default range is
    from to until). See ``from / until`` in the render\_api_ for examples of
    time formats. Datapoints in the range is used to regression.

    Example::

        &target=linearRegression(Server.instance01.threads.busy,'-1d')
        &target=linearRegression(Server.instance*.threads.busy,
                                 "00:00 20140101","11:59 20140630")

    """
    from .app import evaluateTarget
    results = []
    sourceContext = requestContext.copy()
    if startSourceAt is not None:
        sourceContext['startTime'] = parseATTime(startSourceAt)
    if endSourceAt is not None:
        sourceContext['endTime'] = parseATTime(endSourceAt)

    sourceList = []
    for series in seriesList:
        source = evaluateTarget(sourceContext, series.pathExpression)
        sourceList.extend(source)

    for source, series in zip(sourceList, seriesList):
        newName = 'linearRegression(%s, %s, %s)' % (
            series.name,
            int(epoch(sourceContext['startTime'])),
            int(epoch(sourceContext['endTime'])))
        forecast = linearRegressionAnalysis(source)
        if forecast is None:
            continue
        factor, offset = forecast
        values = [offset + (series.start + i * series.step) * factor
                  for i in range(len(series))]
        newSeries = TimeSeries(newName, series.start, series.end,
                               series.step, values)
        newSeries.pathExpression = newSeries.name
        results.append(newSeries)
    return results
Graphs the liner regression function by least squares method.

    Takes one metric or a wildcard seriesList, followed by a quoted string
    with the time to start the line and another quoted string with the time
    to end the line. The start and end times are inclusive (default range is
    from to until). See ``from / until`` in the render\_api_ for examples of
    time formats. Datapoints in the range is used to regression.

    Example::

        &target=linearRegression(Server.instance01.threads.busy,'-1d')
        &target=linearRegression(Server.instance*.threads.busy,
                                 "00:00 20140101","11:59 20140630")