travis-ci-com
72 of 72 new or added lines in 5 files covered. (100.0%)
4660 of 5748 relevant lines covered (81.07%)
10782180.32 hits per line
1 |
# Sampler for Uniform Ball |
|
2 |
|
|
3 |
struct UniformBallSampler
|
|
|
n::Int |
4,000,000✔ |
5 |
end |
|
6 |
|
|
7 |
|
|
8 |
function _rand!(rng::AbstractRNG, spl::UniformBallSampler, x::AbstractVector) |
2,000,000✔ |
|
n = spl.n |
6,000,000✔ |
10 |
# defer to UniformSphericalSampler for calculation of unit-vector |
|
|
_rand!(rng, UniformSphericalSampler(n-1), x)
|
4,000,000✔ |
12 |
|
|
13 |
# re-scale x
|
|
|
u = rand(rng) |
4,000,000✔ |
|
r = (u^inv(n)) |
4,000,000✔ |
|
x .*= r |
6,000,000✔ |
|
return x
|
4,000,000✔ |
18 |
end |
|
19 |
|
|
20 |
|
|
21 |
function _rand!(rng::AbstractRNG, spl::UniformBallSampler, x::AbstractMatrix) |
|
|
for j in axes(x, 2) |
× |
|
_rand!(rng, spl, view(x,:,j)) |
× |
24 |
end |
|
|
return x
|
× |
26 |
end |