Skip to content

Commit

Permalink
testondata.jl split into computing function and drowing finction
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomino committed Jun 23, 2017
1 parent 7cf09d9 commit 7047e15
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 4 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,25 @@ All result files are saved in /res directory. To plot a graph run /res/plotcompt

For the computional example on data use the following.

The script `gandata.jl` generates `t = 100000000` realisations of `n = 4` dimensional data form the `t`-multivariate distribution with `\nu = 14` degrees of freedom, and theoretical
The script `gandata.jl` generates `t = 150000000` realisations of `n = 4` dimensional data form the `t`-multivariate distribution with `\nu = 14` degrees of freedom, and theoretical
super-diagonal elements of those cumulants. Rasults are saved in `data/datafortests.jld`

The script `testondata.jl` computes cumulant tensors of order `m = 1 - 6` for `data/datafortests.jld`, results are saved in `data/cumulants.jld`.

To read `cumulants.jld` please run

```julia
julia> using JLD

julia> using SymmetricTensors

julia> load("cumulants.jld")

```

To plot super-diagonal elements of those cumulants and their theoretical values from t-student dostrobution pleas run `plotsuperdiag.jl`


# Citing this work


Expand Down
48 changes: 48 additions & 0 deletions test/data/plotsuperdiag.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env julia

using JLD
using SymmetricTensors
using PyCall
@pyimport matplotlib as mpl
using PyPlot
mpl.rc("text", usetex=true)
mpl.rc("font", family="serif", size = 8)


"""
pltdiag()
Plots a chart of superdiagonal elements of cumulants of and its theoretical values
"""
function pltdiag()
tdiag = try load("datafortests.jld")["theoretical diag"]
catch
println("please run test/gandata.jl and test/testondata.jl")
return ()
end
cum = try load("cumulants.jld")["cumulants"]
catch
println("please run test/testondata.jl")
return ()
end
n = cum[1].dats
fig, ax = subplots(figsize = (3., 2.3))
col = ["cyan", "brown", "green", "red", "blue", "black"]
for order in (2,4,5,6)
c = cum[order]
ax[:plot](diag(c), "o", color = col[order], label = "$order cumulant", markersize=3)
ax[:plot]([fill(tdiag[order], n)...], "--", color = col[order], label = "theoretical")
end
PyPlot.ylabel("superdiagonal elements", labelpad = -1)
PyPlot.xlabel("superdiagonal number", labelpad = -3)
ax[:legend](fontsize = 4.5, loc = 5)
fig[:savefig]("diagcumels.eps")
end



function main()
pltdiag()
end

main()
2 changes: 1 addition & 1 deletion test/gendata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Returns Matrix{Float64} - t realisations from t-student multivatiate distributio
with nu degress of freedom
"""

function gendat(nu::Int, t::Int = 100000000)
function gendat(nu::Int, t::Int = 150000000)
cm = [[1. 0.7 0.7 0.7];[0.7 1. 0.7 0.7]; [0.7 0.7 1. 0.7]; [0.7 0.7 0.7 1]]
p = MvTDist(nu, [0., 0., 0., 0.],cm)
return transpose(rand(p, t))
Expand Down
4 changes: 2 additions & 2 deletions test/testondata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using JLD
using Cumulants
addprocs()
addprocs(4)
@everywhere using Cumulants

function main()
Expand All @@ -12,7 +12,7 @@ function main()
return ()
end
c = cumulants(d["data"], 6)
save("data/cumulants.jld", Dict("cumulant" => c))
save("data/cumulants.jld", Dict("cumulants" => c))
end

main()

0 comments on commit 7047e15

Please sign in to comment.