Are there any packages that implement INT? This is defined as
where is the probit function, is the rank of observation , and is the number of observations.
I did a bit of googling for this or for probit, but all of the results are about probit link functions in the context of linear modeling for example
StatsFuns.jl has normcdf and norminvcdf
Alternatively, take a look at the erf functions from SpecialFunctions.jl:
https://specialfunctions.juliamath.org/stable/functions_overview/#Error-Functions,-Dawson%E2%80%99s-and-Fresnel-Integrals-1
The Gaussian cdf can be expressed and properly implemented with the erf function
There might be a better way to get the ranks (is there?), but this works:
julia> x = [3,5,2,7]
4-element Vector{Int64}:
3
5
2
7
julia> (1:4)[invperm(sortperm(x))]
4-element Vector{Int64}:
2
3
1
4
@Chad Scherrer That's the way I'd do it :laughing:... well, skipping using the range
julia> sortperm(x) |> invperm
4-element Vector{Int64}:
2
3
1
4
Cool.
using Distributions
using CairoMakie
using StatsFuns
using StatsBase
function invnormaltransform(v; c=3/8)
(μ, σ) = mean_and_var(v)
rank = invperm(sortperm(v))
N = length(v)
return [norminvcdf(μ, σ, (x - c) / (N - 2c + 1)) for x in rank]
end
x = rand(Beta(3, 1), 1000); y = invnormaltransform(x);
hist(x)
hist!(y)
current_figure()
Kevin Bonham has marked this topic as resolved.
Last updated: Nov 22 2024 at 04:41 UTC