Skip to content

Commit 139c4a1

Browse files
authored
small typos in julia code that could be a problem in other languages. Added abs and fixed <= (#840)
* small typo in julia code that could be a problem in other languages * adding absolute value to approximate counting tests in Julia
1 parent 495bc8a commit 139c4a1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

contents/approximate_counting/code/julia/approximate_counting.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function increment(v, a)
1717
delta = 1/(n(v+1, a)-n(v, a))
1818

1919
if rand() <= delta
20-
return v += 1
20+
return v + 1
2121
else
2222
return v
2323
end
@@ -47,7 +47,7 @@ function test_approximate_count(n_trials, n_items, a, threshold)
4747

4848
avg = sum(samples)/n_trials
4949

50-
@test ((avg - n_items) / n_items < threshold)
50+
@test (abs((avg - n_items) / n_items) < threshold)
5151
end
5252

5353
@testset "Counting Tests, 100 trials" begin

0 commit comments

Comments
 (0)