get_critical_value#
- pycafee.sample.studentdistribution.StudentDistribution.get_critical_value(self, gl, alfa=None, which=None)#
This function returns the critical value of the two-side or one-side Student’s t distribution. This is just a wrapper around
stats.t.ppf[1].- Parameters
- gl
int, higher than1 The degree of freedom of the sample
- alfa
float The level of significance,
0.0 < alfa < 1.0.- which
str, optional The parameter which controls the t distribution to be ploted. The options are:
Noneor"two-side"(default): two-side"one-side": one-side
- gl
- Returns
- result
tuple The critical values for a par
glandalpha, whereThe first element is the higher critical value;
The second element is the lower critical value;
The third element is the corresponding alpha value;
The fourth element is the distribution used from the which parameter;
- result
See also
Notes
The critical values for the sample are obtained using the scipy percent point function [1]:
stats.t.ppf(1-alfa/2, gl) or stats.t.ppf(alfa/2, gl) # for the two-side distribution stats.t.ppf(1-alfa, gl) or stats.t.ppf(alfa, gl) # for the one-side distribution
References
- 1(1,2)
SCIPY. scipy.stats.t. Available at: www.scipy.org. Access on: 10 May. 2022.
Examples
Getting the critical values for 4 degrees of freedom at 95% of confidence level (two-side)
>>> from pycafee.sample.studentdistribution import StudentDistribution >>> student = StudentDistribution() >>> result = student.get_critical_value(4) >>> print(result) Student(Upper=2.7764451051977996, Lower=-2.7764451051977996, Alpha=0.05, Distribution='two-side')
Getting the critical values for 5 degrees of freedom at 90% of confidence level (two-side)
>>> from pycafee.sample.studentdistribution import StudentDistribution >>> student = StudentDistribution() >>> result = student.get_critical_value(5, alfa=0.1) >>> print(result) Student(Upper=2.0150483726691575, Lower=-2.0150483726691575, Alpha=0.1, Distribution='two-side')
Getting the critical values for 4 degrees of freedom at 95% of confidence level (one-side)
>>> from pycafee.sample.studentdistribution import StudentDistribution >>> student = StudentDistribution() >>> result = student.get_critical_value(4, which="one-side") Student(Upper=2.13184678133629, Lower=-2.13184678133629, Alpha=0.05, Distribution='one-side')
Getting the critical values for 5 degrees of freedom at 90% of confidence level (one-side)
>>> from pycafee.sample.studentdistribution import StudentDistribution >>> student = StudentDistribution() >>> result = student.get_critical_value(5, which="one-side", alfa=0.1) >>> print(result) Student(Upper=1.4758840487820273, Lower=-1.475884048782027, Alpha=0.1, Distribution='one-side')