Histogram
has field weights
and you can compare them:
julia> using StatsBase, Random; Random.seed!(0);
julia> x1, x2 = rand(100), rand(100);
julia> h1 = fit(Histogram, x1, 0:0.1:1);
julia> h2 = fit(Histogram, x2, 0:0.1:1);
julia> h1.weights .- h2.weights
10-element Vector{Int64}:
4
2
-7
1
-2
-3
0
2
-1
4
which you can visually plot with, e.g., Plots.jl:
julia> using Plots
julia> p1 = plot(h1, α=0.5, lab="x1") ; plot!(p1, h2, α=0.5, lab="x2")
julia> p2 = bar(0:0.1:1, h2.weights - h1.weights, lab="diff")
julia> plot(p1, p2)
Or maybe you meant statistical testing:
julia> using HypothesisTests
julia> ApproximateTwoSampleKSTest(x1,x2)
Approximate two sample Kolmogorov-Smirnov test
----------------------------------------------
Population details:
parameter of interest: Supremum of CDF differences
value under h_0: 0.0
point estimate: 0.1
Test summary:
outcome with 95% confidence: fail to reject h_0
two-sided p-value: 0.6994
Details:
number of observations: [100,100]
KS-statistic: 0.7071067811865475
Finally, the Chi-square test is actually comparing the histograms:
julia> ChisqTest( hcat(h1.weights, h2.weights))
Pearson's Chi-square Test
-------------------------
Population details:
parameter of interest: Multinomial Probabilities
...
Test summary:
outcome with 95% confidence: fail to reject h_0
one-sided p-value: 0.7731
...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…