import GeneralStats as gs
import numpy as np
from scipy.stats import skew
from scipy.stats import kurtosistest
import pandas as pd


if __name__ == "__main__":

    gen=gs.GeneralStats()

    data=np.array([[1, 1, 2, 2, 3],[2, 2, 3, 3, 5],[1, 4, 3, 3, 3],[2, 4, 5, 5, 3]])
    data1=np.array([1,2,3,4,5])

    print("data = ", data)
    print("data1 = ", data1)

    res=gen.average(data,rowvar=True)
    res1=gen.average(data1,rowvar=True)
    print("data平均值 = ",res)
    print("data1平均值 = ",res1)

    data=np.array([[1, 1, 2, 2, 3],[2, 2, 3, 3, 5],[1, 4, 3, 3, 3],[2, 4, 5, 5, 3]])
    data1=np.array([1,2,3,4,5])
    res=gen.median(data,rowvar=True)
    res1=gen.median(data1,rowvar=True)
    print("data中位值 = ",res)
    print("data1中位值 = ",res1)

    data=np.array([[1, 1, 2, 2, 3],[2, 2, 3, 3, 5],[1, 4, 3, 3, 3],[2, 4, 5, 5, 3]])
    data1=np.array([1,2,3,4,5])
    res=gen.mode(data,rowvar=True)
    res1=gen.mode(data1,rowvar=True)
    print("data众数值 = ",res)
    print("data1众数值 = ",res1)

    data=np.array([[1, 1, 2, 2, 3],[2, 2, 3, 3, 5],[1, 4, 3, 3, 3],[2, 4, 5, 5, 3]])
    data1=np.array([1,2,3,4,5])
    res=gen.quantile(data,0.5,rowvar=True,interpolation='lower')      #若元素个数为偶数，则模式为'midpoint'的0.5分位数值等价于中位数
    res1=gen.quantile(data1,0.5,rowvar=True,interpolation='lower')    #若元素个数为奇数，则模式为'lower'的0.5分位数值等价于中位数
    print("data 0.5分位数值 = ",res)
    print("data1 0.5分位数值 = ",res1)
    res=gen.quantile(data,0.25,rowvar=True,interpolation='lower')
    res1=gen.quantile(data1,0.25,rowvar=True,interpolation='lower')
    print("data 0.25分位数值s = ",res)
    print("data1 0.25分位数值 = ",res1)
    res=gen.quantile(data,0.75,rowvar=True,interpolation='lower')
    res1=gen.quantile(data1,0.75,rowvar=True,interpolation='lower')
    print("data 0.75分位数值 = ",res)
    print("data1 0.75分位数值 = ",res1)
    res=gen.quantile(data,1.0,rowvar=True,interpolation='lower')
    res1=gen.quantile(data1,1.0,rowvar=True,interpolation='lower')
    print("data 1.0分位数值 = ",res)
    print("data1 1.0分位数值 = ",res1)

    data=np.array([[1, 1, 2, 2, 3],[2, 2, 3, 3, 5],[1, 4, 3, 3, 3],[2, 4, 5, 5, 3]])
    data1=np.array([1,2,3,4,5])
    res=gen.range(data,rowvar=True)
    res1=gen.range(data1,rowvar=True)
    print("data极差 = ",res)
    print("data1极差 = ",res1)

    data=np.array([[1, 1, 2, 2, 3],[2, 2, 3, 3, 5],[1, 4, 3, 3, 3],[2, 4, 5, 5, 3]])
    data1=np.array([1,2,3,4,5])
    res=gen.variance(data,rowvar=True)
    res1=gen.variance(data1,rowvar=True)
    print("data方差 = ",res)
    print("data1方差 = ",res1)

    data=np.array([[1, 1, 2, 2, 3],[2, 2, 3, 3, 5],[1, 4, 3, 3, 3],[2, 4, 5, 5, 3]])
    data1=np.array([1,2,3,4,5])
    res=gen.standard_dev(data,rowvar=True)
    res1=gen.standard_dev(data1,rowvar=True)
    print("data标准差 = ",res)
    print("data1标准差 = ",res1)

    data=np.array([[1, 1, 2, 2, 3],[2, 2, 3, 3, 5],[1, 4, 3, 3, 3],[2, 4, 5, 5, 3]])
    data1=np.array([1,2,3,4,5])
    res=gen.skewness(data,rowvar=True)
    res1=gen.skewness(data1,rowvar=True)
    print("data偏度 = ",res)
    print("data1偏度 = ",res1)
    res=np.array([skew(data[0]),skew(data[1]),skew(data[2]),skew(data[3])])
    print("使用scipy skew方法验证的data偏度 = ",res)
    res1=np.array(skew(data1))
    print("使用scipy skew方法验证的data1偏度 = ",res1)

    data=np.array([[1, 1, 2, 2, 3],[2, 2, 3, 3, 5],[1, 4, 3, 3, 3],[2, 4, 5, 5, 3]])
    data1=np.array([53, 61, 49, 66, 78, 47])
    res=gen.kurtosis(data,rowvar=True)
    res1=gen.kurtosis(data1,rowvar=True)
    print("data峰度 = ",res)
    print("data1峰度 = ",res1)
    data_0=pd.Series(data[0])
    data_1=pd.Series(data[1])
    data_2=pd.Series(data[2])
    data_3=pd.Series(data[3])
    print("使用pandas kurt方法验证的data峰度 = ",[data_0.kurt(),data_1.kurt(),data_2.kurt(),data_3.kurt()])
    data1=pd.Series(data1)
    print("使用pandas kurt方法验证的data1峰度 = ",data1.kurt())



    




[((10, 8, 10, 25), 'GeneralStats.GeneralStats', 'gs.GeneralStats', ({}, {}), '()', True, 'import GeneralStats as gs\n'), ((12, 9, 12, 84), 'numpy.array', 'np.array', ({(12, 18, 12, 83): '[[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]]'}, {}), '([[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]])', True, 'import numpy as np\n'), ((13, 10, 13, 31), 'numpy.array', 'np.array', ({(13, 19, 13, 30): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', True, 'import numpy as np\n'), ((23, 9, 23, 84), 'numpy.array', 'np.array', ({(23, 18, 23, 83): '[[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]]'}, {}), '([[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]])', True, 'import numpy as np\n'), ((24, 10, 24, 31), 'numpy.array', 'np.array', ({(24, 19, 24, 30): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', True, 'import numpy as np\n'), ((30, 9, 30, 84), 'numpy.array', 'np.array', ({(30, 18, 30, 83): '[[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]]'}, {}), '([[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]])', True, 'import numpy as np\n'), ((31, 10, 31, 31), 'numpy.array', 'np.array', ({(31, 19, 31, 30): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', True, 'import numpy as np\n'), ((37, 9, 37, 84), 'numpy.array', 'np.array', ({(37, 18, 37, 83): '[[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]]'}, {}), '([[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]])', True, 'import numpy as np\n'), ((38, 10, 38, 31), 'numpy.array', 'np.array', ({(38, 19, 38, 30): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', True, 'import numpy as np\n'), ((56, 9, 56, 84), 'numpy.array', 'np.array', ({(56, 18, 56, 83): '[[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]]'}, {}), '([[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]])', True, 'import numpy as np\n'), ((57, 10, 57, 31), 'numpy.array', 'np.array', ({(57, 19, 57, 30): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', True, 'import numpy as np\n'), ((63, 9, 63, 84), 'numpy.array', 'np.array', ({(63, 18, 63, 83): '[[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]]'}, {}), '([[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]])', True, 'import numpy as np\n'), ((64, 10, 64, 31), 'numpy.array', 'np.array', ({(64, 19, 64, 30): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', True, 'import numpy as np\n'), ((70, 9, 70, 84), 'numpy.array', 'np.array', ({(70, 18, 70, 83): '[[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]]'}, {}), '([[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]])', True, 'import numpy as np\n'), ((71, 10, 71, 31), 'numpy.array', 'np.array', ({(71, 19, 71, 30): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', True, 'import numpy as np\n'), ((77, 9, 77, 84), 'numpy.array', 'np.array', ({(77, 18, 77, 83): '[[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]]'}, {}), '([[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]])', True, 'import numpy as np\n'), ((78, 10, 78, 31), 'numpy.array', 'np.array', ({(78, 19, 78, 30): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', True, 'import numpy as np\n'), ((88, 9, 88, 84), 'numpy.array', 'np.array', ({(88, 18, 88, 83): '[[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]]'}, {}), '([[1, 1, 2, 2, 3], [2, 2, 3, 3, 5], [1, 4, 3, 3, 3], [2, 4, 5, 5, 3]])', True, 'import numpy as np\n'), ((89, 10, 89, 44), 'numpy.array', 'np.array', ({(89, 19, 89, 43): '[53, 61, 49, 66, 78, 47]'}, {}), '([53, 61, 49, 66, 78, 47])', True, 'import numpy as np\n'), ((94, 11, 94, 29), 'pandas.Series', 'pd.Series', ({(94, 21, 94, 28): 'data[0]'}, {}), '(data[0])', True, 'import pandas as pd\n'), ((95, 11, 95, 29), 'pandas.Series', 'pd.Series', ({(95, 21, 95, 28): 'data[1]'}, {}), '(data[1])', True, 'import pandas as pd\n'), ((96, 11, 96, 29), 'pandas.Series', 'pd.Series', ({(96, 21, 96, 28): 'data[2]'}, {}), '(data[2])', True, 'import pandas as pd\n'), ((97, 11, 97, 29), 'pandas.Series', 'pd.Series', ({(97, 21, 97, 28): 'data[3]'}, {}), '(data[3])', True, 'import pandas as pd\n'), ((99, 10, 99, 26), 'pandas.Series', 'pd.Series', ({(99, 20, 99, 25): 'data1'}, {}), '(data1)', True, 'import pandas as pd\n'), ((85, 18, 85, 29), 'scipy.stats.skew', 'skew', ({(85, 23, 85, 28): 'data1'}, {}), '(data1)', False, 'from scipy.stats import skew\n'), ((83, 18, 83, 31), 'scipy.stats.skew', 'skew', ({(83, 23, 83, 30): 'data[0]'}, {}), '(data[0])', False, 'from scipy.stats import skew\n'), ((83, 32, 83, 45), 'scipy.stats.skew', 'skew', ({(83, 37, 83, 44): 'data[1]'}, {}), '(data[1])', False, 'from scipy.stats import skew\n'), ((83, 46, 83, 59), 'scipy.stats.skew', 'skew', ({(83, 51, 83, 58): 'data[2]'}, {}), '(data[2])', False, 'from scipy.stats import skew\n'), ((83, 60, 83, 73), 'scipy.stats.skew', 'skew', ({(83, 65, 83, 72): 'data[3]'}, {}), '(data[3])', False, 'from scipy.stats import skew\n')]