1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
############################################################
#                                                          #
#         Virtual Laboratory of Statistics in Python       #
#                                                          #
# Inferential statistics with one population  (12.06.2017) #
#                                                          #                
#         Complutense University of Madrid, Spain          #
#                                                          #
#   THIS SCRIPT IS PROVIDED BY THE AUTHORS "AS IS" AND     #
#   CAN BE USED BY ANYONE FOR THE PURPOSES OF EDUCATION    #
#   AND RESEARCH.                                          #
#                                                          #
############################################################
import scipy.stats as s 

# Obtaining critical values in standard normal table Z:N(0,1) # CASE A: For example, for a level of significance of 5% alpha=0.05;
# area is the confidence level area=1-alpha;
critical_value=s.norm.ppf(area);
print('Case A, -z_alpha = ', -critical_value);

# CASE B: For example, for a level of significance of 5% alpha=0.05;
half_alpha=alpha/2;
# area is the confidence level and half of the significance level area=(1-alpha)+half_alpha;
critical_value=s.norm.ppf(area);
print('Case B, -z_alpha/2 = ',-critical_value," z_alpha/2 = ",critical_value);


# CASE C: For example, for a level of significance of 5% alpha=0.05;
# area is the confidence level area=1-alpha;
critical_value=s.norm.ppf(area);
print('Case C, z_alpha = ',critical_value);