Examples - pi.science.regression.PIExponentialModifiedRegression
1. How to compute exponential modified regression for X and Y values ?
/* change decimal places count in formulas */
PIConfiguration.REGRESSION_DECIMAL_PLACES = 6;
/* - prepare X data for exponential modified regression */
PIVariable X = new PIVariable();
X.addValues( new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } );
/* - prepare Y data for exponential modified regression */
PIVariable Y = new PIVariable();
Y.addValues( new double[] { 57.2, 62.8, 72.2, 81.5, 91.6, 97.1, 99.9, 100.4, 100.6 } );
/* - create and compute regression */
PIExponentialModifiedRegression regression = new PIExponentialModifiedRegression( X, Y );
regression.Calc();
Console.WriteLine( regression.GetTextFormula() );
Console.WriteLine( regression.GetTextFormulaFilled() );
/* - calc prediction for X = 5 */
PIDebug.Blank();
System.out.println( "Prediction for X=5 : " + regression.CalcPredictedY( 5.0 ) );
PIDebug.Blank();
Console.WriteLine( "Prediction errors:" );
Console.WriteLine( regression.getErrors().asString( 5 ) );
Output:
y = gama + A * B^x
y = 106.941931 - 77.322073 * 0.732849^x
Prediction for X=5 : 90.59725012409352
Prediction errors:
6.92348;-2.61473;-4.30876;-3.13900;1.00275;2.13625;1.73627;-0.10883;-1.62744