zoukankan      html  css  js  c++  java
  • 多因子分析

    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    import pandas as pd
    import numpy as np
    import scipy.stats as ss
     
     
    ### 正态分布
    norm_dist = ss.norm.rvs(size=20)
    Normal = ss.normaltest(norm_dist)
    Normal,Pvalue = ss.normaltest(norm_dist)
    print(ss.normaltest(norm_dist))
    print(Pvalue)
     
    ### 卡方分布
    testarray = np.array([[10,10,20],[20,20,20]])
    ss.chi2_contingency(testarray)  ## chi2_contingency(矩阵)
     
    ### t 分布
    a = [3,5,4,6,5,5,4,5,3,6,7,8,7,6,7,8,8,9,9,8,7,7,6,7,8]
    b = [7,8,6,7,8,9,6,6,7,8,8,7,9,10,9,9,8,8,4,4,5,6,9,8,12]
    Ttest_indResult=ss.ttest_ind(a,b)
    #print(ss.ttest_ind(a,b))
    print(Ttest_indResult)
     
    ### 方差检验
    agr1 = [40, 50, 39, 43, 49]
    agr2 = [28, 26, 30, 26, 34]
    agr3 = [38, 39, 43, 32, 36]
    F_onewayResult = ss.f_oneway(agr1,agr2,agr3)
    print(F_onewayResult)
     
     
    ### 线性回归
    from sklearn.linear_model import LinearRegression
    X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
    y = np.dot(X, np.array([1, 2])) + 3
    reg = LinearRegression().fit(X, y)
    reg.score()
    
  • 相关阅读:
    洛谷P5281 [ZJOI2019] Minimax搜索
    势函数
    Comet OJ [Contest #5] 迫真大游戏
    洛谷P3307 [SDOI2013] 项链
    洛谷P5985 [PA2019] Muzyka pop
    CF1205E Expected Value Again
    review
    CF891E Lust
    线性代数
    洛谷P4607 [SDOI2018] 反回文串
  • 原文地址:https://www.cnblogs.com/pupilheart/p/10363527.html
Copyright © 2011-2022 走看看