ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
polyfit.php File Reference

Go to the source code of this file.

Functions

 polyfit ($X, $Y, $n)
 printpoly ($C=null)

Variables

 $X = array(0,1,2,3,4,5)
 $Y = array(4,3,12,67,228, 579)
 $points = new Matrix(array($X, $Y))

Function Documentation

polyfit (   $X,
  $Y,
  $n 
)

Definition at line 18 of file polyfit.php.

References $X, and $Y.

{
for ($i = 0; $i < sizeof($X); ++$i)
for ($j = 0; $j <= $n; ++$j)
$A[$i][$j] = pow($X[$i], $j);
for ($i=0; $i < sizeof($Y); ++$i)
$B[$i] = array($Y[$i]);
$matrixA = new Matrix($A);
$matrixB = new Matrix($B);
$C = $matrixA->solve($matrixB);
return $C->getMatrix(0, $n, 0, 1);
}
printpoly (   $C = null)

Definition at line 30 of file polyfit.php.

{
for($i = $C->m - 1; $i >= 0; --$i) {
$r = $C->get($i, 0);
if ( abs($r) <= pow(10, -9) )
$r = 0;
if ($i == $C->m - 1)
echo $r . "x<sup>$i</sup>";
else if ($i < $C->m - 1)
echo " + " . $r . "x<sup>$i</sup>";
else if ($i == 0)
echo " + " . $r;
}
}

Variable Documentation

$points = new Matrix(array($X, $Y))

Definition at line 46 of file polyfit.php.

Referenced by assAnswerMatchingPair\__construct(), assAnswerErrorText\__construct(), ilObjTestAccess\_isPassed(), ilTestNewScoring\calcReachedPoints(), ilPageQuestionProcessor\calculatePoints(), ilMultipleChoiceWizardInputGUI\checkInput(), ilAnswerWizardInputGUI\checkInput(), ilSingleChoiceWizardInputGUI\checkInput(), assTextQuestionGUI\editQuestion(), assFileUploadGUI\editQuestion(), assOrderingHorizontalGUI\editQuestion(), assTextSubsetGUI\editQuestion(), assNumericGUI\editQuestion(), assJavaAppletGUI\editQuestion(), assFlashQuestionGUI\editQuestion(), assClozeTestGUI\editQuestion(), assOrderingQuestionGUI\editQuestion(), ilQuestionBrowserTableGUI\fillRow(), assNumericImport\fromXML(), assOrderingQuestionImport\fromXML(), ilSCORMCertificateAdapter\getCertificateVariablesForPresentation(), ilCourseObjectiveQuestion\getFinalTestPoints(), TCPDF\getHTMLUnitToUnits(), ilCourseObjectiveQuestion\getMaxPointsByObjective(), ilCourseObjectiveQuestion\getMaxPointsByTest(), ilTestServiceGUI\getPassListOfAnswersWithScoring(), ilCourseObjectiveQuestion\getSelfAssessmentPoints(), assTextSubsetGUI\getSolutionOutput(), assSingleChoiceGUI\getSolutionOutput(), assOrderingQuestionGUI\getSolutionOutput(), assMatchingQuestionGUI\getSolutionOutput(), assClozeTestGUI\getSolutionOutput(), ilTestOutputGUI\outQuestionSummary(), ilPageQuestionProcessor\saveQuestionAnswer(), assClozeGap\setItemPoints(), TCPDF\setPageBoxes(), ilTestScoringGUI\setPointsManual(), TCPDF\startSVGElementHandler(), assTextSubsetExport\toXML(), ilCourseObjectiveQuestion\updateLimits(), HTMLPurifier_AttrDef_HTML_Length\validate(), and assMatchingQuestionGUI\writePostData().

$Y = array(4,3,12,67,228, 579)