ExactWrightFisher.Compute_A∞
— Method Return a sample from the ancestral process A∞(t) of Kingman’s co-
alescent with mutation.
At the moment, this function starts from a rough guess to increase the acceptance rate of the algorithm. The guess is based on a small time step approximation of the transition function.
Examples
julia> ExactWrightFisher.Compute_A∞(1.5, 1.)
2
ExactWrightFisher.Compute_A∞_approx
— Method Normal approximation of the transition function, valid for small time steps. In practice, used when t<=0.05. This is Theorem 1 of Jenkins, P. A., & Spano, D. (2017). Exact simulation of the Wright--Fisher diffusion. The Annals of Applied Probability, 27(3), 1478–1509.
ExactWrightFisher.Wright_Fisher_K_dim_exact_trajectory
— Method Wright_Fisher_K_dim_exact_trajectory(initial_vec::AbstractVector{T}, times::AbstractVector{T}, αvec::AbstractVector{T}; use_progress_meter = false) where T<:Real
Sample exactly a K dimensional Wright-Fisher trajectory. Function may hang for time steps <= 0.05 ...
Arguments
initial_vec
: the starting state.times
: the observation times.αvec
: parameters of the K dimensional Wright-Fisher process.
...
Examples
julia>
α_vec = [1.2,1.4,1.3]
Wright_Fisher_K_dim_exact_trajectory([0.2, 0.4, 0.4], range(0, stop = 1, length = 10), α_vec)
3×11 Array{Float64,2}:
0.2 0.2 0.288971 0.156417 0.0282289 … 0.443116 0.416719 0.435391
0.4 0.4 0.302104 0.526393 0.57872 0.359188 0.36929 0.340048
0.4 0.4 0.408926 0.31719 0.393051 0.197697 0.213991 0.22456
ExactWrightFisher.Wright_Fisher_K_dim_exact_transition
— Method Wright_Fisher_K_dim_exact_transition(xvec::AbstractVector{T}, t::Real, αvec::AbstractVector{T}, sα::Real) where T<:Real
Sample exactly from the K dimensional Wright-Fisher transition function. Function may hang for time steps <= 0.05 ...
Arguments
xvec
: the starting state.t
: the time step.αvec
: parameters of the K dimensional Wright-Fisher process.
...
Examples
julia>
α_vec = [1.2,1.4,1.3]
Wright_Fisher_K_dim_exact_transition([0.2, 0.4, 0.4], 0.5, α_vec)
3-element Array{Float64,1}:
0.37638432059656973
0.18253800610053464
0.44107767330289566
ExactWrightFisher.Wright_Fisher_K_dim_trajectory_with_t005_approx
— Method Wright_Fisher_K_dim_trajectory_with_t005_approx(initial_vec::AbstractVector{T}, times::AbstractVector{T}, αvec::AbstractVector{T}; use_progress_meter = false) where T<:Real
Sample exactly a K dimensional Wright-Fisher trajectory if t > 0.05, and approximately otherwise. See also: Compute_A∞_approx
...
Arguments
initial_vec
: the starting state.times
: the observation times.αvec
: parameters of the K dimensional Wright-Fisher process.
...
Examples
julia> Wright_Fisher_K_dim_trajectory_with_t005_approx(rand(Dirichlet(α_vec |> collect)), range(0, stop = 1, length = 10), α_vec)
4×11 Array{Float64,2}:
1.06585e-5 1.06585e-5 1.08036e-5 … 0.000108104 0.00333635 0.022469
0.000657425 0.000657425 0.00340315 0.0150088 0.0103089 7.54402e-6
0.662003 0.662003 0.837201 0.978252 0.976614 0.943636
0.337329 0.337329 0.159385 0.00663071 0.00974101 0.0338876
ExactWrightFisher.Wright_Fisher_K_dim_transition_with_t005_approx
— Method Wright_Fisher_K_dim_transition_with_t005_approx(xvec::AbstractVector{T}, t::Real, αvec::AbstractVector{T}, sα::Real) where T<:Real
Sample exactly from the K dimensional Wright-Fisher transition function if t > 0.05, and from a normal approximation otherwise. See also: Compute_A∞_approx
...
Arguments
xvec
: the starting state.t
: the time step.αvec
: parameters of the K dimensional Wright-Fisher process.
...
Examples
julia> Wright_Fisher_K_dim_transition_with_t005_approx(rand(Dirichlet(α_vec |> collect)), 0.5, α_vec)
[0.02776997207332505, 0.2336806438432984, 0.07839887060526822, 0.6601505134781083]
ExactWrightFisher.Wright_Fisher_exact_trajectory
— Method Wright_Fisher_exact_trajectory(initial_value::Real, times::AbstractVector{T}, θ_1::Real, θ_2::Real; use_progress_meter = false) where T<:Real
Sample exactly a 1-D Wright-Fisher trajectory. Function may hang for time steps <= 0.05 ...
Arguments
initial_value
: the starting point.times
: the observation times.θ_1, θ_2
: parameters of the 1-D Wright-Fisher process.
...
Examples
julia> ExactWrightFisher.Wright_Fisher_exact_trajectory(0.5, range(0.1, stop = 1, length = 5), 0.75/2, 0.75/2)
[0.5, 0.7391267869778926, 0.9850784214783245, 0.8237514810336812, 0.8039797099052189, 0.6671481291268048]
ExactWrightFisher.Wright_Fisher_exact_trajectory_with_t005_approx
— Method Wright_Fisher_exact_trajectory_with_t005_approx(initial_value::Real, times::AbstractVector{T}, θ_1::Real, θ_2::Real; use_progress_meter = false) where T<:Real
Sample exactly a 1-D Wright-Fisher trajectory if t > 0.05, or approximately otherwise. See also: Compute_A∞_approx
...
Arguments
initial_value
: the starting point.times
: the observation times.θ_1, θ_2
: parameters of the 1-D Wright-Fisher process.
...
Examples
julia> Wright_Fisher_exact_trajectory_with_t005_approx(0.5, range(0.1, stop = 1, length = 5), 0.75/2, 0.75/2)
[0.5, 0.7391267869778926, 0.9850784214783245, 0.8237514810336812, 0.8039797099052189, 0.6671481291268048]
ExactWrightFisher.Wright_Fisher_exact_transition
— Method Wright_Fisher_exact_transition(x::Real, t::Real, θ_1::Real, θ_2::Real)
Sample exactly from the 1-D Wright-Fisher transition function. Function may hang for time steps <= 0.05 ...
Arguments
x
: the starting point.t
: the time step.θ_1, θ_2
: parameters of the 1-D Wright-Fisher process.
...
Examples
julia> ExactWrightFisher.Wright_Fisher_exact_transition(0.5, 0.54, 0.75/2, 0.75/2)
0.9177951585792223
ExactWrightFisher.Wright_Fisher_exact_transition_with_t005_approx
— Method Wright_Fisher_exact_transition_with_t005_approx(x::Real, t::Real, θ_1::Real, θ_2::Real)
Sample exactly from the 1-D Wright-Fisher transition function if t > 0.05, from a normal approximation otherwise. See also: Compute_A∞_approx
...
Arguments
x
: the starting point.t
: the time step.θ_1, θ_2
: parameters of the 1-D Wright-Fisher process.
...
Examples
julia> Wright_Fisher_exact_transition_with_t005_approx(0.5, 0.54, 0.75/2, 0.75/2)
0.9177951585792223
ExactWrightFisher.lgamma_local
— Methodlgamma_local(x)
Local version of the log gamma function, intended to be used on positive values. Actually calling the logabsgamma, so computes the logarithm of absolute value of gamma for Real x and returns log(abs(gamma(x)))
.
...
Arguments
x
: a real number.
...
Examples
julia>lgamma_local(x)
3.1780538303479458
ExactWrightFisher.log_akmθ
— Method log of Eq. (5) of Jenkins, P. A., & Spano, D. (2017). Exact simulation of the Wright--Fisher diffusion. The Annals of Applied Probability, 27(3), 1478–1509.
$$ a_{km}^θ = rac{()θ+2k-1)(θ+m)_{(k-1)}}{m!(k-m)!}$$
ExactWrightFisher.minus_1_power_i
— Methodminus_1_power_i(i::Int64)
Returns $(-1)^i$ with hopefully the least amount of work necessary.
Examples
julia> minus_1_power_i(1)
-1