From 04259b73f37ef81f40cd9a1339c46a194ec635bf Mon Sep 17 00:00:00 2001 From: James Schloss Date: Mon, 23 Aug 2021 18:01:48 +0900 Subject: [PATCH 1/2] small typo in julia code that could be a problem in other languages --- .../approximate_counting/code/julia/approximate_counting.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/approximate_counting/code/julia/approximate_counting.jl b/contents/approximate_counting/code/julia/approximate_counting.jl index 5e1fa86c3..0c6a5722e 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 From 7f8d269c70fe168bdf2f021f9cb6d449df0ce42b Mon Sep 17 00:00:00 2001 From: James Schloss Date: Tue, 24 Aug 2021 12:50:19 +0900 Subject: [PATCH 2/2] adding absolute value to approximate counting tests in Julia --- .../approximate_counting/code/julia/approximate_counting.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/approximate_counting/code/julia/approximate_counting.jl b/contents/approximate_counting/code/julia/approximate_counting.jl index 0c6a5722e..36b07651e 100644 --- a/contents/approximate_counting/code/julia/approximate_counting.jl +++ b/contents/approximate_counting/code/julia/approximate_counting.jl @@ -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