Skip to content

Commit

Permalink
Fix precision in _dft by reducing the magnitude of the argument in cis
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed Jul 17, 2017
1 parent b4a0bc6 commit 3342b25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/univariate/discrete/poissonbinomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ end
if VERSION >= v"0.7.0-DEV.602"
function _dft(x::Vector{T}) where T
n = length(x)
y = Vector{complex(float(T))}(n)
y = zeros(complex(float(T)), n)
@inbounds for j = 0:n-1, k = 0:n-1
y[k+1] += x[j+1] * cis(-2π * j * k / n)
y[k+1] += x[j+1] * cis(-π * float(T)(2 * mod(j * k, n)) / n)
end
return y
end
Expand Down
2 changes: 1 addition & 1 deletion test/poissonbinomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ for (n₁, n₂, n₃, p₁, p₂, p₃) in [(10, 10, 10, 0.1, 0.5, 0.9),
end
m += pmf1[i+1] * mc
end
@test isapprox(pdf(d, k), m, atol=2e-15)
@test isapprox(pdf(d, k), m, atol=5e-16)
end
end

Expand Down

0 comments on commit 3342b25

Please sign in to comment.