Class Sake

Description

This class implements polynomial regression for best fit.

  1.  $sake new Sake(2);
  2.  
  3.  // add data
  4.  $sake->addPoint(1,10);
  5.  $sake->addPoint(2,20);
  6.  $sake->addPoint(3,30);
  7.  
  8.  // solve polynomial
  9.  $sake->solve();
  10.  
  11.  // use polynomial
  12.  $X 4;
  13.  $Y $sake->getRegressionValue($X)// Y = 40

Located in /classes/sake.php (line 31)


	
			
Method Summary
Sake Sake (int $maxDegree, [int $precision = 6])
void addPoint (float $x, float $y)
int getCoefficient (int $exponent)
int getDegree ()
float getRegressionValue (float $x)
void solve ()
Methods
Constructor Sake (line 40)

Contructor.

  • access: public
Sake Sake (int $maxDegree, [int $precision = 6])
  • int $maxDegree: The maximum degree of polynomial.
  • int $precision: The maximum precision of coefficients.
addPoint (line 55)

Add a data point for analysis.

  • access: public
void addPoint (float $x, float $y)
  • float $x: function input value.
  • float $y: function output value.
getCoefficient (line 91)

Return a polynomimal coefficient.

  • return: float coefficient value.
  • access: public
int getCoefficient (int $exponent)
  • int $exponent: the x ^ exponent (0 ... degree)
getDegree (line 101)

Return the polynomimal degree.

  • return: polynomimal degree (0 ... $maxDegree).
  • access: public
int getDegree ()
getRegressionValue (line 77)

Return the polynimal result.

  • return: function output value.
  • access: public
float getRegressionValue (float $x)
  • float $x: function input value.
solve (line 109)

Converts the data into a polynomial.

  • access: public
void solve ()

Documentation generated on Sat, 25 Oct 2008 16:08:04 -0400 by phpDocumentor 1.4.2