Пример #1
0
 def simulation(self):
     sample = bt.sample_distr(self.nums)
     print("Simulation results: ")
     print(
         "Theoretical mean and simulated mean: {},{}\nTheoretical SE and simulated SE: {},{}"
         .format(float('%.4f' % round(st.s_mean(self.nums), 4)),
                 float('%.4f' % round(st.s_mean(sample), 4)),
                 bt.sample_stand_err(self.nums),
                 float('%.4f' % round(st.s_std(sample), 4))))
     bt.b_plot(sample)
Пример #2
0
 def sd(self):
     try:
         if type(self.nums) != np.ndarray:
             raise (NonNumpy)
         if self.nums.shape[0] < 50:
             raise (LengthError)
         return float('%.4f' % round(st.s_std(self.nums), 4))
     except LengthError:
         print("The array of size {} too short".format(self.nums.shape[0]))
     except NonNumpy:
         print("Inapropriate type, pass numpy array")
Пример #3
0
def p_se(n, values):
    try:
        if values <= 0:
            raise (nonNegative)
        if n <= 0:
            raise (nonNegative)
        se = st.s_std(p_obs(n, values)) / (len(p_obs(n, values))**(1 / 2))
        return se
    except nonNegative:
        print("Error: values and n should be greater than 0")
    except:
        print("Error: unknown")
Пример #4
0
def p_zscore(x, n, values):
    try:
        if values <= 0:
            raise (nonNegative)
        if n <= 0:
            raise (nonNegative)
        if x == str(x):
            raise (nonText)
        z = (x - st.s_mean(p_obs(n, values))) / st.s_std(p_obs(n, values))
        return z
    except nonNegative:
        print("Error: values and n should be greater than 0")
    except nonText:
        print("Error: not supporting string, please type a number")
Пример #5
0
 def test_std(self):
     self.assertEqual(st.s_std(self.nums1), 1.4142135623730951)
     self.assertEqual(st.s_std(self.nums2), 1.4142135623730951)
     self.assertEqual(st.s_std(self.nums3), 1.7435595774162693)
     self.assertEqual(st.s_std(self.nums4), 2.8284271247461903)
     self.assertEqual(st.s_std(self.nums5), 2.1540659228538015)
Пример #6
0
def stand_err(nums):
    return float('%.4f' % round((st.s_std(nums) / len(nums)**0.5), 4))
Пример #7
0
 def sd(self):
     return float('%.4f' % round(st.s_std(self.nums), 4))
Пример #8
0
def p_se(n, values):
    se = st.s_std(p_obs(n, values)) / (len(p_obs(n, values))**(1 / 2))
    return se
Пример #9
0
def p_zscore(x, n, values):
    z = (x - st.s_mean(p_obs(n, values))) / st.s_std(p_obs(n, values))
    return z