【问题标题】:Two-sample F-test for equal variances in JuliaJulia 中等方差的两样本 F 检验
【发布时间】:2017-02-19 03:57:06
【问题描述】:

我正在寻找 Julia 中等方差的双样本 F 检验的实现,类似于 MATLAB 中的 vartest2

有这样的实现吗?我已经进行了几次搜索,但一无所获。

【问题讨论】:

    标签: statistics julia


    【解决方案1】:

    AFAIK 这个测试还没有在 Julia 中实现。然而,看看Wikipedia page,它看起来很简单。这是它的第一关:

    #Function for testing equivalence of two variances assuming iid Normal.
    #Return is (rejection_indicator::Int, p-value::Float64, test_stat::Float64)
    using Distributions
    function normvartest{T<:Number}(x::Vector{T}, y::Vector{T} ; alpha::Float64=0.05)
        (length(x) < 2 || length(y) < 2) && return(-1, NaN, NaN)
        fStat = var(x) / var(y)
        fDist = FDist(length(x) - 1, length(y) - 1)
        fCdf = cdf(fDist, fStat)
        fCdf < 0.5 ? (pValue = 2 * fCdf) : (pValue = 2 * (1 - fCdf))
        pValue > alpha ? (h0Int = 0) : (h0Int = 1)
        return(h0Int, pValue, fStat)
    end
    
    #Example of use given null
    x = 10 + randn(1000)
    y = randn(1000)
    normvartest(x, y)
    
    #Example of use given alternative alternative
    x = 10 + randn(1000)
    y = 0.9 * randn(1000)
    normvartest(x, y)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-12
      • 2023-03-23
      • 1970-01-01
      • 2020-06-25
      • 2018-05-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多