Examples - pi.science.regression.PIExponentialRegression
1. How to compute exponential regression for X and Y values ?
/* change decimal places count in formulas */ PIConfiguration.REGRESSION_DECIMAL_PLACES = 6; /* - prepare X data for exponential regression */ PIVariable X = new PIVariable(); X.AddValues( new int[] { 0, 1, 2, 3, 4, 5 } ); /* - prepare Y data for exponential regression */ PIVariable Y = new PIVariable(); Y.AddValues( new int[] { 3, 7, 10, 24, 50, 95 } ); /* - create and compute regression */ PIExponentialRegression ExponentialRegression = new PIExponentialRegression( X, Y ); ExponentialRegression.Calc(); Console.WriteLine( ExponentialRegression.GetTextFormula() ); Console.WriteLine( ExponentialRegression.GetTextFormulaFilled() ); /* - calc prediction for X = 3.5 */ PIDebug.Blank(); Console.WriteLine( "Prediction for X=3.5 : " + ExponentialRegression.CalcPredictedY( 3.5 ) ); PIDebug.Blank(); Console.WriteLine( "Prediction errors:" ); Console.WriteLine( ExponentialRegression.GetErrors().AsString( 5 ) );
Output:
y = A * B^x y = 3.046450 * 1.988035^x Prediction for X=3.5 : 33.75032758924823 Prediction errors: -0.04645;0.94355;-2.04043;0.06320;2.41282;0.39503