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, 'GeneralStats.GeneralStats', 'gs.GeneralStats', ([], {}), True, 'import GeneralStats as gs\n'), (12, 'numpy.array', 'np.array', (['[[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, 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import numpy as np\n'), (23, 'numpy.array', 'np.array', (['[[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, 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import numpy as np\n'), (30, 'numpy.array', 'np.array', (['[[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, 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import numpy as np\n'), (37, 'numpy.array', 'np.array', (['[[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, 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import numpy as np\n'), (56, 'numpy.array', 'np.array', (['[[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, 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import numpy as np\n'), (63, 'numpy.array', 'np.array', (['[[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, 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import numpy as np\n'), (70, 'numpy.array', 'np.array', (['[[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, 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import numpy as np\n'), (77, 'numpy.array', 'np.array', (['[[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, 'numpy.array', 'np.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import numpy as np\n'), (88, 'numpy.array', 'np.array', (['[[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, 'numpy.array', 'np.array', (['[53, 61, 49, 66, 78, 47]'], {}), True, 'import numpy as np\n'), (94, 'pandas.Series', 'pd.Series', (['data[0]'], {}), True, 'import pandas as pd\n'), (95, 'pandas.Series', 'pd.Series', (['data[1]'], {}), True, 'import pandas as pd\n'), (96, 'pandas.Series', 'pd.Series', (['data[2]'], {}), True, 'import pandas as pd\n'), (97, 'pandas.Series', 'pd.Series', (['data[3]'], {}), True, 'import pandas as pd\n'), (99, 'pandas.Series', 'pd.Series', (['data1'], {}), True, 'import pandas as pd\n'), (85, 'scipy.stats.skew', 'skew', (['data1'], {}), False, 'from scipy.stats import skew\n'), (83, 'scipy.stats.skew', 'skew', (['data[0]'], {}), False, 'from scipy.stats import skew\n'), (83, 'scipy.stats.skew', 'skew', (['data[1]'], {}), False, 'from scipy.stats import skew\n'), (83, 'scipy.stats.skew', 'skew', (['data[2]'], {}), False, 'from scipy.stats import skew\n'), (83, 'scipy.stats.skew', 'skew', (['data[3]'], {}), False, 'from scipy.stats import skew\n')]