https://github.com/tpapp/stansamples.jl
Read samples from CmdStan into vectors of the appropriate Julia type.
https://github.com/tpapp/stansamples.jl
Last synced: over 1 year ago
JSON representation
Read samples from CmdStan into vectors of the appropriate Julia type.
- Host: GitHub
- URL: https://github.com/tpapp/stansamples.jl
- Owner: tpapp
- License: mit
- Created: 2017-05-09T09:09:39.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-25T19:39:27.000Z (over 3 years ago)
- Last Synced: 2025-02-28T16:20:13.696Z (over 1 year ago)
- Language: Julia
- Size: 107 KB
- Stars: 4
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# StanSamples.jl

[](https://github.com/tpapp/StanSamples.jl/actions?query=workflow%3ACI)
[](http://codecov.io/github/tpapp/StanSamples.jl?branch=master)
Read Stan samples from a CSV file. Columns that belong to the same variable are grouped into arrays.
```julia
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
```