diff --git a/corr_boot.jl b/corr_boot.jl index 3d07ca8..b06f75c 100644 --- a/corr_boot.jl +++ b/corr_boot.jl @@ -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 @@ -37,14 +38,16 @@ 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) @@ -52,34 +55,35 @@ function bootstrap(fs, M) 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) \ No newline at end of file +close(output_file)