# I know that the isapprox() function exists but IMO, it's a mess as it doesn't cover # the real possibility of one of the two inputs being zero while its tolerance parameters # don't have any real value in data science. This function here is designed to be used # for checking if two variances are equal, before applying a t-test on the corresponding variables. # # Compatible with Julia 1.6 """ Usage: MoreOrLessEqual(x, y, [ret]) where x, y = (non-negative) numbers to be compared ret = relative error threshold; optional, defaulting to 10% or 0.1 """ function MoreOrLessEqual(x::Real, y::Real, ret::Float64 = 0.1) if x < eps() || y < eps(); return false; end m, M = ifelse(x < y, (x, y), (y, x)) return M <= m*(1.0 + ret) end