Skip to content

Commit

Permalink
Update corr_boot.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
joott authored Sep 23, 2023
1 parent 0677124 commit d179be6
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions corr_boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ cd("/share/tmschaef/jkott/modelB")
using DelimitedFiles
using Random
using Glob
using Plots

const L = parse(Int, ARGS[1])

function autocor_loc_2(x, beg, max, n=2)
C = zeros(ComplexF64,max+1)
N = zeros(Int64,max+1)
Threads.@threads for tau in 0:max
for tau in 0:max
for i in beg:length(x)-max
j = i + tau
@inbounds @fastmath C[tau+1] = C[tau+1] + (x[i]*conj(x[j]))^n
Expand Down Expand Up @@ -37,49 +38,52 @@ end

function bootstrap(fs, M)
len = length(fs)
bs_tot = []
for i in 1:M
#bs_tot = []
bs_tot = fill(zeros(div(L^4, 40)+1), M)
@Threads.threads for i in 1:M
bsD = []
for j in 1:len
samp = fs[rand(1:len)]
push!(bsD, samp)
end
push!(bs_tot, average(bsD))
#push!(bs_tot, average(bsD))
bs_tot[i] = average(bsD)
end
mean = average(bs_tot)
var = variance(bs_tot)
(mean, sqrt.(var))
end

function collect_data()
dfs = glob("dynamics_L_8_id_*")
datasets = []
for file in dfs
df = readdlm(file,' ')
C = corr(df, 8)
push!(datasets, C)
dfs = glob("dynamics_L_$(L)_id_*")
datasets = fill(zeros(div(L^4, 40)+1), length(dfs))
@Threads.threads for i in 1:length(dfs)
df = readdlm(dfs[i],' ')
C = corr(df, L)
#push!(datasets, C)
datasets[i] = C
end

(C_8, Cerr_8) = bootstrap(datasets, 100)
(C, Cerr) = bootstrap(datasets, 50000)
step = 10
Δt = 0.04
t = [0:length(C_8)-1;] .* (step*Δt)
(t, C_8, Cerr_8)
t = [0:length(C)-1;] .* (step*Δt)
(t, C, Cerr)
end

(t, C, err) = collect_data()

output_file = open("data_8.jl","w")
output_file = open("data_$L.jl","w")

write(output_file, "t_8 = ")
write(output_file, "t_$L = ")
show(output_file, t)
write(output_file, "\n\n")

write(output_file, "C_8 = ")
write(output_file, "C_$L = ")
show(output_file, C)
write(output_file, "\n\n")

write(output_file, "Cerr_8")
write(output_file, "Cerr_$L = ")
show(output_file, err)

close(output_file)
close(output_file)

0 comments on commit d179be6

Please sign in to comment.