Skip to content

Commit

Permalink
rerendered
Browse files Browse the repository at this point in the history
  • Loading branch information
daslu committed Mar 9, 2024
1 parent f71bca8 commit 00d6d38
Show file tree
Hide file tree
Showing 12 changed files with 4,690 additions and 4,277 deletions.
366 changes: 225 additions & 141 deletions docs/index.html

Large diffs are not rendered by default.

88 changes: 53 additions & 35 deletions docs/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ include-in-header: {text: '<link rel = "icon" href = "data:," />'}
border-style: none;
}
</style>
<script src="index_files/md-default2.js" type="text/javascript"></script><script src="index_files/md-default3.js" type="text/javascript"></script><script src="index_files/vega4.js" type="text/javascript"></script><script src="index_files/vega5.js" type="text/javascript"></script><script src="index_files/vega6.js" type="text/javascript"></script>
<script src="index_files/md-default5.js" type="text/javascript"></script><script src="index_files/md-default6.js" type="text/javascript"></script><script src="index_files/vega7.js" type="text/javascript"></script><script src="index_files/vega8.js" type="text/javascript"></script><script src="index_files/vega9.js" type="text/javascript"></script>

# cmdstan-clj

[cmdstan-clj](https://github.com/scicloj/cmdstan-clj) is a Clojure wrapper of [Stan](https://mc-stan.org/) probabilistic programming language that uses the [CmdStan](https://mc-stan.org/users/interfaces/cmdstan) CLI.

**Source:** [![(GitHub repo)](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/scicloj/cmdstan-clj)

**Artifact:** [![(Clojars coordinates)](https://img.shields.io/clojars/v/org.scicloj/cmdstan-clj.svg)](https://clojars.org/org.scicloj/cmdsta-nclj)

**Status:** an evolving proof-of-concept.



::: {.sourceClojure}
```clojure
Expand All @@ -28,6 +37,7 @@ include-in-header: {text: '<link rel = "icon" href = "data:," />'}
[scicloj.noj.v1.vis.hanami :as hanami]
[aerial.hanami.templates :as ht]
[scicloj.kindly.v4.kind :as kind]
[scicloj.noj.v1.stats :as stats]
[scicloj.cmdstan-clj.v1.api :as stan]))
```
:::
Expand Down Expand Up @@ -167,12 +177,12 @@ method = sample (Default)
num_chains = 4
id = 1 (Default)
data
file = /tmp/scicloj-files/session-dir-11604659191568896558/file-12504373429944319048.json
file = /tmp/scicloj-files/session-dir-11604659191568896558/file-5927151010105410628.json
init = 2 (Default)
random
seed = 742505681 (Default)
seed = 744677578 (Default)
output
file = /tmp/scicloj-files/session-dir-11604659191568896558/file-17124531096619153906.csv
file = /tmp/scicloj-files/session-dir-11604659191568896558/file-1500244170315440438.csv
diagnostic_file = (Default)
refresh = 100 (Default)
sig_figs = -1 (Default)
Expand All @@ -181,8 +191,8 @@ output
num_threads = 1 (Default)


Gradient evaluation took 4e-06 seconds
1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds.
Gradient evaluation took 6e-06 seconds
1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
Adjust your expectations accordingly!


Expand Down Expand Up @@ -255,8 +265,8 @@ Chain [2] Iteration: 1900 / 2000 [ 95%] (Sampling)
Chain [2] Iteration: 2000 / 2000 [100%] (Sampling)

Elapsed Time: 0.002 seconds (Warm-up)
0.005 seconds (Sampling)
0.007 seconds (Total)
0.006 seconds (Sampling)
0.008 seconds (Total)

Chain [3] Iteration: 1 / 2000 [ 0%] (Warmup)
Chain [3] Iteration: 100 / 2000 [ 5%] (Warmup)
Expand Down Expand Up @@ -330,30 +340,30 @@ Here are the sampels:

model samples [4000 10]:

| :lp__ | :accept_stat__ | :stepsize__ | :treedepth__ | :n_leapfrog__ | :divergent__ | :energy__ | :theta | :i | :chain |
|---------:|---------------:|------------:|-------------:|--------------:|-------------:|----------:|----------:|----:|-------:|
| -7.41382 | 1.000000 | 0.777441 | 1 | 1 | 0 | 7.85868 | 0.1269450 | 0 | 0 |
| -7.41382 | 0.550202 | 0.777441 | 1 | 3 | 0 | 13.02730 | 0.1269450 | 1 | 0 |
| -7.41228 | 1.000000 | 0.777441 | 1 | 1 | 0 | 7.52623 | 0.1270600 | 2 | 0 |
| -7.37431 | 1.000000 | 0.777441 | 1 | 1 | 0 | 7.50176 | 0.1299770 | 3 | 0 |
| -6.93588 | 0.931852 | 0.777441 | 1 | 3 | 0 | 8.12785 | 0.3312790 | 4 | 0 |
| -6.80454 | 0.967858 | 0.777441 | 1 | 3 | 0 | 7.13454 | 0.2096250 | 5 | 0 |
| -6.79949 | 1.000000 | 0.777441 | 1 | 1 | 0 | 6.81325 | 0.2113960 | 6 | 0 |
| -6.79284 | 1.000000 | 0.777441 | 1 | 1 | 0 | 6.80609 | 0.2138760 | 7 | 0 |
| -6.86624 | 0.995038 | 0.777441 | 2 | 3 | 0 | 6.86643 | 0.1927360 | 8 | 0 |
| -6.88913 | 0.995606 | 0.777441 | 1 | 1 | 0 | 6.90740 | 0.1878160 | 9 | 0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| -7.44225 | 0.837832 | 1.054200 | 1 | 3 | 0 | 7.52977 | 0.4123490 | 989 | 3 |
| -7.14448 | 1.000000 | 1.054200 | 1 | 1 | 0 | 7.43295 | 0.3705500 | 990 | 3 |
| -6.76120 | 0.986628 | 1.054200 | 2 | 3 | 0 | 7.24248 | 0.2300850 | 991 | 3 |
| -7.08888 | 0.729946 | 1.054200 | 2 | 3 | 0 | 8.44645 | 0.1573260 | 992 | 3 |
| -7.29277 | 0.962178 | 1.054200 | 1 | 1 | 0 | 7.32332 | 0.1367060 | 993 | 3 |
| -7.20813 | 1.000000 | 1.054200 | 1 | 1 | 0 | 7.35312 | 0.1444920 | 994 | 3 |
| -7.00512 | 0.787117 | 1.054200 | 2 | 3 | 0 | 10.29140 | 0.1682220 | 995 | 3 |
| -7.52014 | 0.922386 | 1.054200 | 1 | 3 | 0 | 7.52022 | 0.1194030 | 996 | 3 |
| -7.20534 | 0.910383 | 1.054200 | 1 | 3 | 0 | 8.46004 | 0.3800390 | 997 | 3 |
| -6.87471 | 1.000000 | 1.054200 | 1 | 1 | 0 | 7.10577 | 0.3161360 | 998 | 3 |
| -7.94309 | 0.665075 | 1.054200 | 1 | 3 | 0 | 8.96780 | 0.0957875 | 999 | 3 |
| :lp__ | :accept_stat__ | :stepsize__ | :treedepth__ | :n_leapfrog__ | :divergent__ | :energy__ | :theta | :i | :chain |
|---------:|---------------:|------------:|-------------:|--------------:|-------------:|----------:|---------:|----:|-------:|
| -8.11236 | 0.852541 | 0.911611 | 1 | 1 | 0 | 8.21981 | 0.482261 | 0 | 0 |
| -7.09564 | 1.000000 | 0.911611 | 1 | 1 | 0 | 7.84041 | 0.362438 | 1 | 0 |
| -6.98290 | 1.000000 | 0.911611 | 1 | 1 | 0 | 7.10100 | 0.341409 | 2 | 0 |
| -7.29832 | 0.921769 | 0.911611 | 1 | 1 | 0 | 7.31091 | 0.393478 | 3 | 0 |
| -7.05176 | 0.824162 | 0.911611 | 1 | 3 | 0 | 8.42956 | 0.161917 | 4 | 0 |
| -7.06956 | 0.997314 | 0.911611 | 1 | 1 | 0 | 7.11572 | 0.159674 | 5 | 0 |
| -6.98819 | 1.000000 | 0.911611 | 2 | 3 | 0 | 7.07702 | 0.170687 | 6 | 0 |
| -6.96291 | 1.000000 | 0.911611 | 2 | 3 | 0 | 7.01444 | 0.174576 | 7 | 0 |
| -6.84479 | 0.961321 | 0.911611 | 1 | 3 | 0 | 7.34808 | 0.307478 | 8 | 0 |
| -6.84954 | 0.998868 | 0.911611 | 1 | 1 | 0 | 6.87052 | 0.308926 | 9 | 0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| -6.74831 | 1.000000 | 1.023060 | 2 | 3 | 0 | 7.12938 | 0.247004 | 989 | 3 |
| -6.74831 | 0.683211 | 1.023060 | 1 | 3 | 0 | 8.29214 | 0.247004 | 990 | 3 |
| -6.74802 | 0.999438 | 1.023060 | 2 | 3 | 0 | 6.75135 | 0.249930 | 991 | 3 |
| -6.74937 | 0.938038 | 1.023060 | 2 | 3 | 0 | 7.07479 | 0.243541 | 992 | 3 |
| -6.83419 | 0.977264 | 1.023060 | 1 | 3 | 0 | 6.85396 | 0.304116 | 993 | 3 |
| -6.76144 | 0.994745 | 1.023060 | 1 | 3 | 0 | 6.86275 | 0.229907 | 994 | 3 |
| -6.79718 | 0.987858 | 1.023060 | 1 | 3 | 0 | 6.83401 | 0.290490 | 995 | 3 |
| -7.01616 | 0.931399 | 1.023060 | 1 | 1 | 0 | 7.01719 | 0.348021 | 996 | 3 |
| -9.68096 | 0.376511 | 1.023060 | 1 | 1 | 0 | 9.68218 | 0.594334 | 997 | 3 |
| -7.10940 | 1.000000 | 1.023060 | 1 | 1 | 0 | 8.74168 | 0.364773 | 998 | 3 |
| -6.74823 | 0.932219 | 1.023060 | 2 | 3 | 0 | 7.45066 | 0.252559 | 999 | 3 |



Expand All @@ -364,14 +374,22 @@ The histogram of $\theta$:
```clojure
(-> sampling
:samples
(hanami/histogram :theta {:nbins 100}))
(tc/group-by [:chain] {:result-type :as-map})
(update-vals
(fn [chain-samples]
(-> chain-samples
(hanami/histogram :theta {:nbins 100})))))
```
:::



```{=html}
<div><script>vegaEmbed(document.currentScript.parentElement, {"encoding":{"y":{"field":"count","type":"quantitative"},"x":{"scale":{"zero":false},"field":"left","type":"quantitative","title":"theta"},"y2":{"field":0,"type":"quantitative"},"x2":{"scale":{"zero":false},"field":"right","type":"quantitative"}},"mark":"rect","width":400,"background":"floralwhite","height":300,"data":{"url":"index_files\/0.csv","format":{"type":"csv"}}});</script></div>
<div><p>{</p><div style="margin-left:10%;width:110%;"><table><tr><td valign="top"><div><pre><code class="sourceCode language-clojure printed-clojure">{:chain 0}
</code></pre></div></td><td><div style="margin-left:10px;"><div><script>vegaEmbed(document.currentScript.parentElement, {"encoding":{"y":{"field":"count","type":"quantitative"},"x":{"scale":{"zero":false},"field":"left","type":"quantitative","title":"theta"},"y2":{"field":0,"type":"quantitative"},"x2":{"scale":{"zero":false},"field":"right","type":"quantitative"}},"mark":"rect","width":400,"background":"floralwhite","height":300,"data":{"url":"index_files\/0.csv","format":{"type":"csv"}}});</script></div></div></td></tr></table><table><tr><td valign="top"><div><pre><code class="sourceCode language-clojure printed-clojure">{:chain 1}
</code></pre></div></td><td><div style="margin-left:10px;"><div><script>vegaEmbed(document.currentScript.parentElement, {"encoding":{"y":{"field":"count","type":"quantitative"},"x":{"scale":{"zero":false},"field":"left","type":"quantitative","title":"theta"},"y2":{"field":0,"type":"quantitative"},"x2":{"scale":{"zero":false},"field":"right","type":"quantitative"}},"mark":"rect","width":400,"background":"floralwhite","height":300,"data":{"url":"index_files\/1.csv","format":{"type":"csv"}}});</script></div></div></td></tr></table><table><tr><td valign="top"><div><pre><code class="sourceCode language-clojure printed-clojure">{:chain 2}
</code></pre></div></td><td><div style="margin-left:10px;"><div><script>vegaEmbed(document.currentScript.parentElement, {"encoding":{"y":{"field":"count","type":"quantitative"},"x":{"scale":{"zero":false},"field":"left","type":"quantitative","title":"theta"},"y2":{"field":0,"type":"quantitative"},"x2":{"scale":{"zero":false},"field":"right","type":"quantitative"}},"mark":"rect","width":400,"background":"floralwhite","height":300,"data":{"url":"index_files\/2.csv","format":{"type":"csv"}}});</script></div></div></td></tr></table><table><tr><td valign="top"><div><pre><code class="sourceCode language-clojure printed-clojure">{:chain 3}
</code></pre></div></td><td><div style="margin-left:10px;"><div><script>vegaEmbed(document.currentScript.parentElement, {"encoding":{"y":{"field":"count","type":"quantitative"},"x":{"scale":{"zero":false},"field":"left","type":"quantitative","title":"theta"},"y2":{"field":0,"type":"quantitative"},"x2":{"scale":{"zero":false},"field":"right","type":"quantitative"}},"mark":"rect","width":400,"background":"floralwhite","height":300,"data":{"url":"index_files\/3.csv","format":{"type":"csv"}}});</script></div></div></td></tr></table></div><p>}</p></div>
```


Expand All @@ -392,7 +410,7 @@ The trace plot of $\theta$:


```{=html}
<div><script>vegaEmbed(document.currentScript.parentElement, {"encoding":{"y":{"field":"theta","type":"quantitative"},"color":{"field":"chain","type":"nominal"},"opacity":{"value":0.5},"x":{"field":"i","type":"quantitative"}},"mark":{"type":"line","tooltip":true},"width":400,"background":"floralwhite","height":300,"data":{"url":"index_files\/1.csv","format":{"type":"csv"}}});</script></div>
<div><script>vegaEmbed(document.currentScript.parentElement, {"encoding":{"y":{"field":"theta","type":"quantitative"},"color":{"field":"chain","type":"nominal"},"opacity":{"value":0.5},"x":{"field":"i","type":"quantitative"}},"mark":{"type":"line","tooltip":true},"width":400,"background":"floralwhite","height":300,"data":{"url":"index_files\/4.csv","format":{"type":"csv"}}});</script></div>
```


Expand Down
200 changes: 100 additions & 100 deletions docs/index_files/0.csv
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
count,left,right
2,0.00848121,0.014972277899999999
1,0.014972277899999999,0.0214633458
4,0.0214633458,0.027954413699999996
9,0.027954413699999996,0.034445481599999994
13,0.034445481599999994,0.0409365495
25,0.0409365495,0.0474276174
22,0.0474276174,0.05391868529999999
21,0.05391868529999999,0.0604097532
30,0.0604097532,0.0669008211
37,0.0669008211,0.073391889
37,0.073391889,0.0798829569
45,0.0798829569,0.08637402479999999
50,0.08637402479999999,0.0928650927
63,0.0928650927,0.09935616059999999
60,0.09935616059999999,0.1058472285
67,0.1058472285,0.1123382964
73,0.1123382964,0.11882936429999999
76,0.11882936429999999,0.1253204322
75,0.1253204322,0.13181150009999998
66,0.13181150009999998,0.138302568
82,0.138302568,0.14479363589999997
90,0.14479363589999997,0.15128470379999998
99,0.15128470379999998,0.15777577169999998
69,0.15777577169999998,0.16426683959999996
103,0.16426683959999996,0.17075790749999997
67,0.17075790749999997,0.17724897539999998
78,0.17724897539999998,0.1837400433
84,0.1837400433,0.19023111119999997
69,0.19023111119999997,0.19672217909999998
75,0.19672217909999998,0.20321324699999999
91,0.20321324699999999,0.20970431489999997
80,0.20970431489999997,0.21619538279999997
87,0.21619538279999997,0.22268645069999998
75,0.22268645069999998,0.22917751859999996
98,0.22917751859999996,0.23566858649999997
92,0.23566858649999997,0.24215965439999998
76,0.24215965439999998,0.24865072229999996
81,0.24865072229999996,0.2551417902
87,0.2551417902,0.2616328581
74,0.2616328581,0.268123926
55,0.268123926,0.2746149939
84,0.2746149939,0.2811060618
86,0.2811060618,0.2875971297
66,0.2875971297,0.2940881976
68,0.2940881976,0.30057926549999997
65,0.30057926549999997,0.3070703334
59,0.3070703334,0.3135614013
54,0.3135614013,0.32005246919999997
60,0.32005246919999997,0.3265435371
63,0.3265435371,0.333034605
49,0.333034605,0.3395256729
69,0.3395256729,0.3460167408
55,0.3460167408,0.3525078087
38,0.3525078087,0.3589988766
55,0.3589988766,0.3654899445
45,0.3654899445,0.3719810124
43,0.3719810124,0.3784720803
37,0.3784720803,0.3849631482
45,0.3849631482,0.3914542161
29,0.3914542161,0.397945284
31,0.397945284,0.4044363519
29,0.4044363519,0.41092741979999997
25,0.41092741979999997,0.4174184877
21,0.4174184877,0.4239095556
22,0.4239095556,0.43040062349999997
26,0.43040062349999997,0.4368916914
21,0.4368916914,0.4433827593
22,0.4433827593,0.44987382719999996
23,0.44987382719999996,0.4563648951
13,0.4563648951,0.462855963
25,0.462855963,0.46934703089999996
11,0.46934703089999996,0.4758380988
16,0.4758380988,0.4823291667
14,0.4823291667,0.48882023459999996
16,0.48882023459999996,0.4953113025
15,0.4953113025,0.5018023704
9,0.5018023704,0.5082934383
14,0.5082934383,0.5147845061999999
10,0.5147845061999999,0.5212755741
6,0.5212755741,0.527766642
7,0.527766642,0.5342577099
10,0.5342577099,0.5407487778
13,0.5407487778,0.5472398457
4,0.5472398457,0.5537309135999999
2,0.5537309135999999,0.5602219815
4,0.5602219815,0.5667130494
5,0.5667130494,0.5732041173
7,0.5732041173,0.5796951852
5,0.5796951852,0.5861862530999999
4,0.5861862530999999,0.5926773209999999
1,0.5926773209999999,0.5991683889
2,0.5991683889,0.6056594568
2,0.6056594568,0.6121505247
2,0.6121505247,0.6186415926
0,0.6186415926,0.6251326604999999
1,0.6251326604999999,0.6316237283999999
2,0.6316237283999999,0.6381147963
0,0.6381147963,0.6446058642
1,0.6446058642,0.6510969321
1,0.6510969321,0.657588
3,0.0188005,0.025394455000000003
2,0.025394455000000003,0.03198841
6,0.03198841,0.03858236500000001
5,0.03858236500000001,0.045176320000000006
7,0.045176320000000006,0.051770275000000004
9,0.051770275000000004,0.05836423
9,0.05836423,0.064958185
10,0.064958185,0.07155214
12,0.07155214,0.078146095
7,0.078146095,0.08474005
16,0.08474005,0.091334005
19,0.091334005,0.09792796000000001
22,0.09792796000000001,0.104521915
15,0.104521915,0.11111587
15,0.11111587,0.117709825
15,0.117709825,0.12430378
19,0.12430378,0.13089773500000002
14,0.13089773500000002,0.13749169
20,0.13749169,0.144085645
23,0.144085645,0.1506796
14,0.1506796,0.157273555
22,0.157273555,0.16386751
21,0.16386751,0.170461465
21,0.170461465,0.17705542000000002
20,0.17705542000000002,0.183649375
20,0.183649375,0.19024333000000002
22,0.19024333000000002,0.196837285
30,0.196837285,0.20343124
19,0.20343124,0.210025195
18,0.210025195,0.21661915
16,0.21661915,0.223213105
16,0.223213105,0.22980706
26,0.22980706,0.23640101500000002
15,0.23640101500000002,0.24299497
11,0.24299497,0.24958892500000002
22,0.24958892500000002,0.25618288
17,0.25618288,0.26277683500000004
22,0.26277683500000004,0.26937079
17,0.26937079,0.275964745
14,0.275964745,0.2825587
15,0.2825587,0.28915265500000004
17,0.28915265500000004,0.29574661
12,0.29574661,0.302340565
34,0.302340565,0.30893452
19,0.30893452,0.31552847500000003
15,0.31552847500000003,0.32212243
21,0.32212243,0.328716385
15,0.328716385,0.33531034000000004
19,0.33531034000000004,0.341904295
15,0.341904295,0.34849825
10,0.34849825,0.355092205
10,0.355092205,0.36168616000000003
10,0.36168616000000003,0.368280115
7,0.368280115,0.37487407
8,0.37487407,0.381468025
14,0.381468025,0.38806198000000003
10,0.38806198000000003,0.394655935
8,0.394655935,0.40124989
7,0.40124989,0.40784384500000004
3,0.40784384500000004,0.4144378
8,0.4144378,0.421031755
5,0.421031755,0.42762571
6,0.42762571,0.43421966500000003
5,0.43421966500000003,0.44081362
6,0.44081362,0.447407575
5,0.447407575,0.45400153000000004
5,0.45400153000000004,0.460595485
5,0.460595485,0.46718944
8,0.46718944,0.473783395
5,0.473783395,0.48037735000000004
5,0.48037735000000004,0.486971305
3,0.486971305,0.49356526
1,0.49356526,0.500159215
4,0.500159215,0.5067531700000001
3,0.5067531700000001,0.513347125
5,0.513347125,0.51994108
2,0.51994108,0.526535035
0,0.526535035,0.53312899
1,0.53312899,0.5397229450000001
1,0.5397229450000001,0.5463169
2,0.5463169,0.552910855
2,0.552910855,0.5595048100000001
1,0.5595048100000001,0.566098765
3,0.566098765,0.57269272
3,0.57269272,0.579286675
1,0.579286675,0.58588063
1,0.58588063,0.592474585
1,0.592474585,0.59906854
0,0.59906854,0.605662495
0,0.605662495,0.6122564500000001
1,0.6122564500000001,0.618850405
0,0.618850405,0.62544436
0,0.62544436,0.6320383150000001
1,0.6320383150000001,0.63863227
0,0.63863227,0.645226225
0,0.645226225,0.6518201800000001
0,0.6518201800000001,0.658414135
0,0.658414135,0.66500809
0,0.66500809,0.671602045
1,0.671602045,0.678196
Loading

0 comments on commit 00d6d38

Please sign in to comment.