Student.cin

From TORI
Jump to navigation Jump to search

// Student.cin is C++ float implementation the first ten density functions of the Student Distribution.

float Student(int n,float x)
{float c[11]={0.,
0.31830988618379,
0.35355339059327,
0.36755259694786,
0.37500000000000,
0.37960668982249,
0.38273277230987,
0.38499145083227,
0.38669902096139,
0.38803490887167,
0.38910838396603};
return c[n]*pow(1.+x*x/n, -0.5*(n+1));
}

if n==0 echo " Attempt to evaluate density of the Student Distribution with zero degrees of freedom is detected. Sorry, but you need some freedom in order to perform the calculus. The country has performed an illegal operation (elimination of all freedoms) and will be shut down. In order to save your computer and your life, move your computer out from the country, where all degrees of freedom are eliminated. Then clean your harddisk, screen of your monitor and your keyboard with ethanol.";


PHP

The testing of the coefficients can be performed with php code below:

<?php
echo 1/M_PI, "\n";
echo 1/sqrt(8), "\n";
echo 2/(M_PI*sqrt(3)), "\n";
echo 3/8, "\n";
echo 8/(3*M_PI*sqrt(5)), "\n";
echo 0, "\n";
echo 1/sqrt(2*M_PI), "\n";
?>

Warning

At the translation of code from PHP to C++, do not forget to add dot (.) to the numerical constants.

References

Keywords

«C++», «[[]]», «Density of probability», «PHP», «Student Distribution»,