function secondordercalibration($X, $Y, $ConfidenceInterval)
 {
     $numX = count($X);
     $numY = count($Y);
     if ($numX != $numY) {
         die("Error: Size of X and Y vectors must be the same.");
     }
     if ($numX <= 1) {
         die("Error: Size of input array must be at least 2.");
     }
     //General parameters
     $this->n = $numX;
     $this->X = $X;
     $this->Y = $Y;
     //second-order parameters
     $this->XMean = $this->getMean($this->X);
     $this->YMean = $this->getMean($this->Y);
     $this->SumXX = $this->getSumXX();
     $this->SumX2Y = $this->getSumX2Y();
     $this->SumXY = $this->getSumXY();
     $this->SumX4 = $this->getSumX4();
     $this->SumX3 = $this->getSumX3();
     $this->SumX2 = $this->getSumX2();
     $this->SumX = $this->getSumX();
     $this->SumY = $this->getSumY();
     $this->Den = $this->getDen();
     $this->SOc = $this->getSOc();
     //Second order c parameter.
     $this->SOb = $this->getSOb();
     //Second order b parameter.
     $this->SOa = $this->getSOa();
     //Second order a parameter.
     $this->Slope = $this->getSlope();
     $this->PredictedY = $this->getPredictedY();
     $this->Error = $this->getError();
     $this->SquaredError = $this->getSquaredError();
     $this->SumError = $this->getSumError();
     $this->SumSquaredError = $this->getSumSquaredError();
     $this->ErrorVariance = $this->getErrorVariance();
     $this->StdErr = $this->getStdErr();
     $this->RStdErr = $this->getRStdErr();
     $this->RStdErr100 = $this->getRStdErr100();
     $this->Infpoint = $this->getInfpoint();
     $this->SumYY = $this->getSumYY();
     $this->RSquared = $this->getRSquared();
     $this->CCalfa = $this->getCCalfa();
     $this->CCbeta = $this->getCCbeta();
     $this->ConfInt = $ConfidenceInterval;
     $this->Alpha = (100 - $this->ConfInt) / 100;
     $this->Delta = 2 * (100 - $this->ConfInt) / 100;
     //One tail aproximation according to ISO 11843-2
     //Probability parameters
     $dist = new SchemA();
     $this->AlphaTVal = $dist->getInverseStudentT($this->Alpha, $this->X);
     $this->DeltaTVal = $dist->getInverseStudentT($this->Delta, $this->X);
     return true;
 }
 function linearcalibration($X, $Y, $ConfidenceInterval, $W)
 {
     $numX = count($X);
     $numY = count($Y);
     if ($numX != $numY) {
         die("Error: Size of X and Y vectors must be the same.");
     }
     if ($numX <= 1) {
         die("Error: Size of input array must be at least 2.");
     }
     //General parameters
     $this->n = $numX;
     $this->X = $X;
     $this->Y = $Y;
     $this->W = $W;
     //Confidence interval
     $this->ConfInt = $ConfidenceInterval;
     $this->Alpha = (100 - $this->ConfInt) / 100;
     $this->Delta = 2 * (100 - $this->ConfInt) / 100;
     //One tail aproximation according to ISO 11843-2
     //Linear parameters
     $this->XMean = $this->getMean($this->X);
     $this->YMean = $this->getMean($this->Y);
     $this->SumXX = $this->getSumXX();
     $this->SumYY = $this->getSumYY();
     $this->SumXY = $this->getSumXY();
     $this->Slope = $this->getSlope();
     $this->YInt = $this->getYInt();
     $this->PredictedY = $this->getPredictedY();
     $this->Error = $this->getError();
     $this->SquaredError = $this->getSquaredError();
     $this->SumError = $this->getSumError();
     $this->SumSquaredError = $this->getSumSquaredError();
     $this->ErrorVariance = $this->getErrorVariance();
     $this->StdErr = $this->getStdErr();
     $this->RStdErr = $this->getRStdErr();
     $this->RStdErr100 = $this->getRStdErr100();
     $this->RSDErrFR = $this->getRSDErrFR();
     $this->SlopeStdErr = $this->getSlopeStdErr();
     $this->YIntStdErr = $this->getYIntStdErr();
     $this->SlopeTVal = $this->getSlopeTVal();
     $this->YIntTVal = $this->getYIntTVal();
     $this->R = $this->getR();
     $this->RSquared = $this->getRSquared();
     $this->DF = $this->getDF();
     $this->CCalfa = $this->getCCalfa();
     $this->CCbeta = $this->getCCbeta();
     $this->ConfIntOfSlope = $this->getConfIntOfSlope();
     //Weight parameters
     $this->SumW = $this->getSumW();
     $this->SumWX = $this->getSumWX();
     $this->SumWXX = $this->getSumWXX();
     $this->SumWYY = $this->getSumWYY();
     $this->SumWX2 = $this->getSumWX2();
     $this->SumWY2 = $this->getSumWY2();
     $this->SumWY = $this->getSumWY();
     $this->SumWXY = $this->getSumWXY();
     $this->SlopeW = $this->getSlopeW();
     $this->YIntW = $this->getYIntW();
     $this->RW = $this->getRW();
     $this->RSquaredW = $this->getRSquaredW();
     $this->PredictedYW = $this->getPredictedYW();
     $this->ErrorW = $this->getErrorW();
     $this->SquaredErrorW = $this->getSquaredErrorW();
     $this->SumErrorW = $this->getSumErrorW();
     $this->SumSquaredErrorW = $this->getSumSquaredErrorW();
     $this->ErrorVarianceW = $this->getErrorVarianceW();
     $this->StdErrW = $this->getStdErrW();
     $this->RStdErrW = $this->getRStdErrW();
     $this->RStdErrW100 = $this->getRStdErrW100();
     $this->CCalfaW = $this->getCCalfaW();
     $this->CCbetaW = $this->getCCbetaW();
     //Probability parameters
     $dist = new SchemA();
     $this->SlopeProb = $dist->getStudentT($this->SlopeTVal, $this->DF);
     $this->YIntProb = $dist->getStudentT($this->YIntTVal, $this->DF);
     $this->AlphaTVal = $dist->getInverseStudentT($this->Alpha, $this->X);
     $this->DeltaTVal = $dist->getInverseStudentT($this->Delta, $this->X);
     return true;
 }