StanSamples.jl

Read samples from CmdStan into vectors of the appropriate Julia type.
Author tpapp
Popularity
4 Stars
Updated Last
1 Year Ago
Started In
May 2017

StanSamples.jl

lifecycle build codecov.io

Read Stan samples from a CSV file. Columns that belong to the same variable are grouped into arrays.

julia> using StanSamples

julia> DATA = "a,b.1,b.2,c.1.1,c.2.1,c.1.2,c.2.2\n" *
              "1.0,2.0,3.0,4.0,5.0,6.0,7.0\n" *
              "8.0,9.0,10.0,11.0,12.0,13.0,14.0"

julia> samples = read_samples(IOBuffer(DATA));

julia> samples.a
2-element Array{Float64,1}:
 1.0
 8.0

julia> samples.b
2×2 ElasticArrays.ElasticArray{Float64,2,1}:
 2.0   9.0
 3.0  10.0

julia> samples.c
2×2×2 ElasticArrays.ElasticArray{Float64,3,2}:
[:, :, 1] =
 4.0  6.0
 5.0  7.0

[:, :, 2] =
 11.0  13.0
 12.0  14.0

julia> header, matrix = read_sample_matrix(IOBuffer(DATA))

julia> header, matrix = read_sample_matrix(io);

julia> header
7-element Vector{SubString{String}}:
 "a"
 "b.1"
 "b.2"
 "c.1.1"
 "c.2.1"
 "c.1.2"
 "c.2.2"

julia> matrix
2×7 Matrix{Float64}:
 1.0  2.0   3.0   4.0   5.0   6.0   7.0
 8.0  9.0  10.0  11.0  12.0  13.0  14.0

Used By Packages

No packages found.