diff --git a/contents/approximate_counting/code/julia/approximate_counting.jl b/contents/approximate_counting/code/julia/approximate_counting.jl index 5e1fa86c3..36b07651e 100644 --- a/contents/approximate_counting/code/julia/approximate_counting.jl +++ b/contents/approximate_counting/code/julia/approximate_counting.jl @@ -17,7 +17,7 @@ function increment(v, a) delta = 1/(n(v+1, a)-n(v, a)) if rand() <= delta - return v += 1 + return v + 1 else return v end @@ -47,7 +47,7 @@ function test_approximate_count(n_trials, n_items, a, threshold) avg = sum(samples)/n_trials - @test ((avg - n_items) / n_items < threshold) + @test (abs((avg - n_items) / n_items) < threshold) end @testset "Counting Tests, 100 trials" begin