Skip to content

Commit

Permalink
Fixed CI (moved pip install upwards) + fixed W_coeff bug (declaring o…
Browse files Browse the repository at this point in the history
…nly z as symbol)
  • Loading branch information
fargolo committed Sep 22, 2023
1 parent 1e370e0 commit b4b5110
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/AnalyticComb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using SymPy
#using DynamicalSystems

export
p_binary_word_runs
p_binary_words_runl

include("binary_words.jl")
#include("inference_plot.jl")
Expand Down
7 changes: 5 additions & 2 deletions src/binary_words.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ n_tot defaults to 200, according to the example in Flajolet & Sedgewick pag. 52
"""
function W_coeff(r;n_tot=200)

@vars z r n
z = SymPy.symbols('z')
w_rr(r,z) = (1-z^(r+1))/(1-2z+z^(r+1)) # OGF
#w_rr(r,z) = sum(z^x for x in 0:r)/(1 - sum(z^x for x in 1:r)) # Alternate form

Expand All @@ -22,14 +22,17 @@ function W_coeff(r;n_tot=200)

end




"""
p_binary_word_runs(k,n)
Returns probablity associatied with k-lenght run in a sequence of size n.
Refer to the example in Flajolet & Sedgewick pag. 52.
"""
function p_binary_word_runs(k,n)
function p_binary_words_runl(k,n)
#a = FastRational{Int128}(1/(2^n))
#a = Rational{BigInt}(1/(2^n))
a = 1//(BigInt(2)^n)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Test

@testset "AnalyticComb.jl" begin

results = map(i->p_binary_word_runs(i,200),3:12)
results = map(i->p_binary_words_runl(i,200),3:12)

# Check if any of the results presents error > 0.01
@test sum(results - map(x-> round(x;digits=3),[6.549422864002916e-8,
Expand Down

0 comments on commit b4b5110

Please sign in to comment.