Skip to content

Commit

Permalink
Remove sum (does pairwise addition?)
Browse files Browse the repository at this point in the history
  • Loading branch information
BioTurboNick committed May 4, 2023
1 parent 2363f8f commit 0b0a61a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/gamma_inc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,11 @@ function gamma_inc_taylor(a::Float64, x::Float64, ind::Integer)
sm += t
end

# Sum terms from small to large
sm += sum(reverse!(@view wk[1:i]))
# sum terms from small to large
for v @view wk[i:-1:1]
sm += v
end

p = (rgammax(a, x) / a) * (1.0 + sm)
return (p, 1.0 - p)
end
Expand Down Expand Up @@ -486,8 +489,11 @@ function gamma_inc_asym(a::Float64, x::Float64, ind::Integer)
sm += t
end

# Sum terms from small to large
sm += sum(reverse!(@view wk[1:i]))
# sum terms from small to large
for v @view wk[i:-1:1]
sm += v
end

q = (rgammax(a, x) / x) * (1.0 + sm)
return (1.0 - q, q)
end
Expand Down

0 comments on commit 0b0a61a

Please sign in to comment.