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())



    




[((178, 195), 'GeneralStats.GeneralStats', 'gs.GeneralStats', ([], {}), '()\n', (193, 195), True, 'import GeneralStats as gs\n'), ((208, 286), 'numpy.array', 'np.array', (['[[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]])\n', (216, 286), True, 'import numpy as np\n'), ((295, 320), 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), '([1, 2, 3, 4, 5])\n', (303, 320), True, 'import numpy as np\n'), ((531, 609), 'numpy.array', 'np.array', (['[[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]])\n', (539, 609), True, 'import numpy as np\n'), ((618, 643), 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), '([1, 2, 3, 4, 5])\n', (626, 643), True, 'import numpy as np\n'), ((790, 868), 'numpy.array', 'np.array', (['[[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]])\n', (798, 868), True, 'import numpy as np\n'), ((877, 902), 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), '([1, 2, 3, 4, 5])\n', (885, 902), True, 'import numpy as np\n'), ((1045, 1123), 'numpy.array', 'np.array', (['[[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]])\n', (1053, 1123), True, 'import numpy as np\n'), ((1132, 1157), 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), '([1, 2, 3, 4, 5])\n', (1140, 1157), True, 'import numpy as np\n'), ((2074, 2152), 'numpy.array', 'np.array', (['[[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]])\n', (2082, 2152), True, 'import numpy as np\n'), ((2161, 2186), 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), '([1, 2, 3, 4, 5])\n', (2169, 2186), True, 'import numpy as np\n'), ((2329, 2407), 'numpy.array', 'np.array', (['[[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]])\n', (2337, 2407), True, 'import numpy as np\n'), ((2416, 2441), 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), '([1, 2, 3, 4, 5])\n', (2424, 2441), True, 'import numpy as np\n'), ((2590, 2668), 'numpy.array', 'np.array', (['[[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]])\n', (2598, 2668), True, 'import numpy as np\n'), ((2677, 2702), 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), '([1, 2, 3, 4, 5])\n', (2685, 2702), True, 'import numpy as np\n'), ((2861, 2939), 'numpy.array', 'np.array', (['[[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]])\n', (2869, 2939), True, 'import numpy as np\n'), ((2948, 2973), 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), '([1, 2, 3, 4, 5])\n', (2956, 2973), True, 'import numpy as np\n'), ((3323, 3401), 'numpy.array', 'np.array', (['[[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]])\n', (3331, 3401), True, 'import numpy as np\n'), ((3410, 3444), 'numpy.array', 'np.array', (['[53, 61, 49, 66, 78, 47]'], {}), '([53, 61, 49, 66, 78, 47])\n', (3418, 3444), True, 'import numpy as np\n'), ((3597, 3615), 'pandas.Series', 'pd.Series', (['data[0]'], {}), '(data[0])\n', (3606, 3615), True, 'import pandas as pd\n'), ((3628, 3646), 'pandas.Series', 'pd.Series', (['data[1]'], {}), '(data[1])\n', (3637, 3646), True, 'import pandas as pd\n'), ((3659, 3677), 'pandas.Series', 'pd.Series', (['data[2]'], {}), '(data[2])\n', (3668, 3677), True, 'import pandas as pd\n'), ((3690, 3708), 'pandas.Series', 'pd.Series', (['data[3]'], {}), '(data[3])\n', (3699, 3708), True, 'import pandas as pd\n'), ((3820, 3836), 'pandas.Series', 'pd.Series', (['data1'], {}), '(data1)\n', (3829, 3836), True, 'import pandas as pd\n'), ((3251, 3262), 'scipy.stats.skew', 'skew', (['data1'], {}), '(data1)\n', (3255, 3262), False, 'from scipy.stats import skew\n'), ((3129, 3142), 'scipy.stats.skew', 'skew', (['data[0]'], {}), '(data[0])\n', (3133, 3142), False, 'from scipy.stats import skew\n'), ((3143, 3156), 'scipy.stats.skew', 'skew', (['data[1]'], {}), '(data[1])\n', (3147, 3156), False, 'from scipy.stats import skew\n'), ((3157, 3170), 'scipy.stats.skew', 'skew', (['data[2]'], {}), '(data[2])\n', (3161, 3170), False, 'from scipy.stats import skew\n'), ((3171, 3184), 'scipy.stats.skew', 'skew', (['data[3]'], {}), '(data[3])\n', (3175, 3184), False, 'from scipy.stats import skew\n')]