-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathppl_intro.jl
More file actions
2453 lines (2023 loc) · 92 KB
/
ppl_intro.jl
File metadata and controls
2453 lines (2023 loc) · 92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
### A Pluto.jl notebook ###
# v0.19.6
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
el
end
end
# ╔═╡ ab655734-a8b7-47db-9b73-4099c4b11dfc
begin
using CSV, DataFrames
using LinearAlgebra, PDMats
using Optim, ForwardDiff
using Turing, Distributions
using MCMCChains
using Plots, StatsPlots, PairPlots, LaTeXStrings, ColorSchemes
using PlutoUI, HypertextLiteral
# Set a seed for reproducibility.
using Random
Random.seed!(0)
if false
# Hide the progress prompt while sampling.
#Turing.setprogress!(false);
import Logging
Logging.disable_logging(Logging.Warn)
end
end;
# ╔═╡ 1c651c38-d151-11ec-22a6-87180bd6546a
md"""
# Lab 12: Probabilistic Programming Languages
#### [Penn State Astroinformatics Summer School 2022](https://sites.psu.edu/astrostatistics/astroinfo-su22-program/)
#### [Eric Ford](https://www.personal.psu.edu/ebf11)
"""
# ╔═╡ eb9c3330-89a9-4c8e-9eae-cd227599e144
md"""
## Overview
In this lab, we'll analyze measurements of the transit times of the planet Kepler-26b (also known as KOI 250.01) from [Holczer et al. (2016)](https://ui.adsabs.harvard.edu/abs/2016ApJS..225....9H/abstract).
First, we'll fit a standard linear model using conventional techniques.
Then, we'll demonstrate how to use a probabilistic programming language (PPL) to model the data.
You'll see how we can use the PPL to easily revise the model to consider alternative choices for the prior distribution and/or likelihood.
You'll get a chance to compare the posterior samples and posterior predictive distributions based.
The purpose of this lab is for you to appreciate how using a PPL provides greater modeling flexibility that deriving results analytically. Thus, you can efficiently explore your data using multiple statistical models to better understand the sensitivity of your results to the inevitable assumptions.
### Read the data
"""
# ╔═╡ d49b2d7a-fabe-4525-a11c-8e808960fc96
begin
data_path = "data/koi250.01.csv" # Data from Mazeh et al. 2013 ApJS 208, 16 (Table 2)
df = CSV.read(data_path, select=[:n, :t, :σₜ], DataFrame) # t is BJD-2454900
df.σₜ ./= 24*60 # convert units of uncertainties from minutes to days
nobs = size(df,1)
df
end
# ╔═╡ 90ae54f1-c49d-4d66-82eb-eb783c389e54
md"""
### Plot the data
It's often good to make a quick plot to help understand the characteristics of the data. For this data set, the transit times ($t$) are very nearly a linear function of the transit number ($n$). While the measurement uncertainties are plotted, it's hard to see them in this plot.
"""
# ╔═╡ efcabcc4-40ed-4492-b3e4-e190be248fce
scatter(df.n, df.t, yerr=df.σₜ, label=:none, xlabel="Transit #", ylabel="Time (d)" )
# ╔═╡ c0e7a487-e8eb-4078-a473-e5fe64245f4c
md"""
### Ordinary linear regression
If we did not have access to measurement uncertainties (and were willing to assume i.i.d. Gaussian measurement noise), then we would likely start by computing the best fit linear fit with simple linear algebra
```math
\left[ \begin{matrix} t_1 \\ t_2 \\ \vdots \\ t_{n_{nobs}} \end{matrix} \right]
=
\left[ \begin{matrix}
1 & n_1 \\
1 & n_2 \\
\vdots & \vdots \\
1 & n_{nobs}
\end{matrix} \right]
\left[ \begin{matrix} t_0 \\ P \end{matrix} \right]
```
where the left-hand side are the observed transit times, and the right-hand side includes the design matrix and the two parameters to be estimated. More generally, we could write this as
$y_{\mathrm{obs}} = \mathbf{A} b$ and compute the maximum likelihood estimate for $b$, $b_{mle} = \mathbf{A}^{-1} y_{\mathrm{obs}}$.
"""
# ╔═╡ 7242adfc-a0bc-4603-ae8a-8198e5647c6d
A = [ones(nobs) df.n]
# ╔═╡ 939c5578-3806-4938-9f24-8cb4cf8afe90
b_mle_ols = A \ df.t
# ╔═╡ 3221c380-e04f-4822-ac5f-48add15aa757
md"""
In astronomy, we often have (estiamtes of) measurement uncertainties. In this case, the data set provides an estimated standard deviation for each measurement, $\sigma_t$.
Our model for each observation is
$\mathrm{t}_i \sim \mathrm{Normal}(t0 + \mathrm{period} \cdot n_i, \sigma_{t,i}^2)$
We still compute the maximum likelihood estimates of $b$ accounting for this noise model, using
$b_{mle} = (A' {\Sigma}^{-1} A)^{-1} (A' \mathbf{\Sigma}^{-1} y_{obs})$.
In this case, the covariance matrix, $\mathbf{\Sigma}$, contains $\sigma_{t}$'s along the diagonal (allowing for more efficient calculations than if it were an arbitrary positive definite matrix).
"""
# ╔═╡ a77dd7a7-c9f7-4a93-9b85-207f88196650
begin
covar = PDiagMat(df.σₜ)
coef_mle_linalg_w_covar = Xt_invA_X(covar, A) \ (A' * (covar \ df.t) )
end
# ╔═╡ 2190ad8c-5a49-43da-a1b7-efa8c22205d0
md"(While the results are similar, there is a small difference.)"
# ╔═╡ 8c73c50f-6f60-4ca8-a1d2-71e31f39b859
coef_mle_linalg_w_covar .- b_mle_ols
# ╔═╡ 68532fbf-f5bd-4fae-ae63-0000a9b64e12
md"""
Since the above calculations reduce to linear algebra, they are very fast (for small to moderate sized data sets like this one). However, there are some important limitations.
**Question:** Think of some scientific reasons why one might need a more flexible approach, even for a data set where the underlying physics is linear?
!!! hint "Hint"
- What if we wanted to compute the maximum *a posteriori* value of $b$, $b_{map}$, using non-Gaussian priors?
- What if we wanted to compute uncertainties on our model parameters that account for those priors?
- What if we wanted to allow for measurement errors that are non-Gaussian?
"""
# ╔═╡ 504f77c4-41db-4f70-b402-380fde67410d
md"""
## Probabilistic Programming Languages
**Probabilistic Programming Languages (PPLs)** make it easy for one to specify complex models. There are many PPLs. We'll be using [Turing.jl](https://turing.ml/dev/docs/using-turing/quick-start) below.
"""
# ╔═╡ 1ac81243-19d4-47a2-8520-a4010ecb63a8
md"""
In PPLs, one doesn't specify how to compute the target distribution (e.g., the posterior probability distribution). Instead, one specifies the distribution of all stochastic variables in a model. The compiler figures out how to compute the required distributions.
While there are inevitably differences in capabilities, efficiency and syntax, most modern PPLs adopt the common notation:
`x ~ Distribution`
to indicate that the random variable $x$ is drawn from a given distribution. PPLs include many common distributions like `Uniform(a,b)`, `Normal(μ,σ)`, etc. (Many PPLs now allow you to implement your own distributions, too.)
Some PPLs go so far as using a *[declarative programming](https://en.wikipedia.org/wiki/Declarative_programming)* model (as opposed to an imperative programming where one specifies each step of the calculation in order). This can create some limitations (e.g., can't interoperate with functions to perform non-standard mathematical calculations). Turing takes an approach where the order of commands does matter (e.g., you can only access a variable after it has been assigned a value or a distribution). Turing still figures out how to sample from the prior and posterior probability distributions for the programmer.
Inspect the code below for a Turing model for Bayesian linear regression.
"""
# ╔═╡ b8ab2460-7c59-4e87-8580-e7b49f0576aa
@model function linear_regression(x, y, σ_y)
# Specify priors for model parameters
t0 ~ Uniform(0, 1200) # Time of 0th transit
period ~ Uniform(1,100) # Orbital period
# Specify liklihood
for i ∈ eachindex(y)
t_pred = t0 + period * x[i] # Predicted transit time given t0 and period
y[i] ~ Normal(t_pred, σ_y[i]) # Error model
end
end
# ╔═╡ 77799e4f-0aea-4fd4-9a85-a22eba5ab2d4
md"""
Let's pause to note a few things about our model:
1. We had to specify prior distributions for our model parameters, `t0` and `period`. Sometimes just writing your model in a PPL can be helpful because it forces you to be explicit about all your assumptions.
2. Our model is a function that takes argument `x`, `y` and `σ_y`. For our application these will be arrays containing the transit number, observed transit time and measurement uncertainties.
3. Our model includes standard Julia code, such as the `for` loop over observations and calculating `t_pred`. (While most PPLs allow for deterministic nodes like `t_pred`, many PPLs are much more restrictive than Turing.)
"""
# ╔═╡ 81c18249-5951-48d9-a194-7f8e814cf8a3
md"""
In order to get a model that is conditioned on our observational data, we call the model function and pass the transit numbers, observed transit times and measurement uncertainties contained in the dataframe, `df`.
"""
# ╔═╡ 9926a73d-c8d0-4d83-9720-4313d82532bc
model_given_data = linear_regression(df.n, df.t, df.σₜ)
# ╔═╡ 86cb312e-84df-42a4-bad5-2d74abca2560
md"""
### Optimizing Model Parameters
Now we can use the model in a variety of ways. For example, we can compute the maximum likelihood estimate and/or maximum *a posterior* parameters. While not required, we'll provide a not-too-bad initial guess, so the calculations will be a little faster and reduce risk of bad convergence.
"""
# ╔═╡ c142f016-4b8d-4035-9dde-6c802c334546
init_guess = [ 100.0, 10.0]
# ╔═╡ 93ba5f00-a494-4c1c-8690-d50e3b398a7c
mle_estimate = optimize(model_given_data, MLE(), init_guess)
# ╔═╡ 8317710d-50b5-4958-9a85-611133fd6ab8
map_estimate = optimize(model_given_data, MAP(), init_guess)
# ╔═╡ 4ffc0147-9477-4cfd-acc5-5ca7994caf20
md"""
Since our model might contains many parameters, it would be easy to lose track of which index is which variable. Therefore, it's better to refer to variables by name like.
"""
# ╔═╡ 64bd0fcb-9e16-4ecd-ab4f-c0ddf08df0f2
begin
period_map = map_estimate.values[:period]
t0_map = map_estimate.values[:t0]
period_mle = mle_estimate.values[:period]
t0_mle = mle_estimate.values[:t0]
(;period_mle, t0_mle)
end
# ╔═╡ 62f0b1e4-2885-433c-a13d-c87d6ae2fd9b
md"We can compute the log prior and log likelihood for any set of model parameters."
# ╔═╡ 8114804f-8ca8-43f0-b1d7-7c014270a77e
logprior(model_given_data, (;period=period_mle, t0=t0_mle ) )
# ╔═╡ 308c16b2-0eb4-4df5-9436-ed6d6908f58c
max_log_likelihood = loglikelihood(model_given_data, (;period=period_mle, t0=t0_mle ) )
# ╔═╡ bda05df7-0bc1-4025-88ac-109c0136618f
max_log_joint = logjoint(model_given_data, (;period=period_map, t0=t0_map ) )
# ╔═╡ 325a5daf-e849-443c-95d8-630fe2d850c2
let
x = range(t0_map-0.002, stop=t0_map+0.002, length=80)
y = range(period_map-0.00005, stop=period_map+0.00005, length=80)
scatter([t0_map],[period_map], mc=:red, markershape=:x,label=:none)
contour!(x, y, (x,y)-> logjoint(model_given_data, (;period=y, t0=x ) ), levels=range(max_log_joint, step=-1, stop=max_log_joint-10), c=:red )
xlabel!(L"t_0 (d)")
ylabel!("Period (d)")
end
# ╔═╡ 8e208838-f22b-4c3e-a814-f5353d772efe
md"""
### Sampling from Posterior
In this case, we know the posterior will be very nearly Gaussian, but for more complex models, we might want to use Markov chain Monte Carlo (MCMC) methods to compute posterior samples. We'll demonstrate that below.
(There's a checkbox to turn these calculation on/off, since they can be somewhat slow and increase the latency of interacting with other parts of the notebook.
There's also a box to select the number of iterations to run the MCMC chains for. The default value is far too low to use for any scientific purposes. But it might be wise to see how long it takes the notebook to update on your system, before deciding how many iterations to request.)
"""
# ╔═╡ d5ece785-d20e-4f91-90b4-74fa8de3d433
@bind mcmc_linear confirm( PlutoUI.combine() do Child
md"""
I want to run MCMC sampler: $(Child("run", CheckBox()))
Samples from Markov chain: $(Child("num_iterations",NumberField(100:100:5000, default=100)))
"""
end )
# ╔═╡ 74f458e5-8aaf-4895-ade9-df982c30b555
if mcmc_linear.run
chain = sample(model_given_data, NUTS(0.65), mcmc_linear.num_iterations, init_params=collect(mle_estimate.values)) #, save_state=true)
end
# ╔═╡ 010d65b9-d612-4dff-ac52-8dd376f54b6c
md"""
Here we used the No U-Turn Sampler ([NUTS](http://turing.ml/docs/library/#-turingnuts--type)) which makes use of the target density's gradients to efficiently propose trial steps in the Markov chain.
"""
# ╔═╡ e881c5af-b1da-45e6-8e43-fd81ac8f0daf
md"The sampler returns the results of one (or more) MCMC chains that can be used for inference. For example, we can get some summary statistics about the model parameters and their convergence diagnostics. For this model and data set, the mean parameter values should be quite close to the results of our previous estimates above."
# ╔═╡ 1731226b-ae56-4966-a949-1feb182fd315
if mcmc_linear.run
describe(chain)
end
# ╔═╡ 43b13b5c-98af-4912-8258-981231fce046
md"""
And we can visually inspect the trace plots for our parameters and kernel density estimates of the marginal posterior densities.
"""
# ╔═╡ aa4e5b88-cac6-4b0f-8db7-a58c6a9e3bca
if mcmc_linear.run
plot(chain)
end
# ╔═╡ 32b7e852-efdc-493a-b09e-4e5c9a764bf9
md"It can also be useful to visualize the 2-d path that the MCMC through the parameter space."
# ╔═╡ 88032f2c-0b79-4b7f-b066-dc5b3c8a34f9
if mcmc_linear.run
md"Number of iterations to plot: $(@bind max_plt_iter Slider(1:size(chain.value,1)))"
end
# ╔═╡ 41b961b4-b248-47b0-8404-cef362e09159
if mcmc_linear.run
let
x = range(t0_map-0.002, stop=t0_map+0.002, length=80)
y = range(period_map-0.00005, stop=period_map+0.00005, length=80)
scatter([t0_map],[period_map], mc=:red, markershape=:x,label=:none)
contour!(x, y, (x,y)-> logjoint(model_given_data, (;period=y, t0=x ) ), levels=range(max_log_joint, step=-1, stop=max_log_joint-10), c=:red )
xlabel!(L"t_0 (d)")
ylabel!("Period (d)")
plot!(chain.value[1:max_plt_iter,:t0,1], chain.value[1:max_plt_iter,:period,1], ms=2.5, markershape=:circle, markerstrokewidth=0, label=:none, alpha=0.66 )
end
end
# ╔═╡ 667a3efc-1746-4997-8b85-04e96a0183cf
md"""
### Posterior Predictive Distribution
If we wanted to compute a sample from the posterior predictive distribution for the transit times, we can create another model which conditions on the transit number and the measurement uncertainties, but does *not* condition on the observations. Then we can use predict, passing the new model and the parameter values from our previous Markov chain. The resulting dataframe includes a sample of predictions for each transit time (named `y[i]`, since that's the name we used in the definition of `linear_regression`).
"""
# ╔═╡ a6b03a32-38d0-4ad0-82a5-1b51d5f4991f
if mcmc_linear.run
model_given_data_wo_y = linear_regression(df.n, missings(nobs), df.σₜ)
pred = predict(model_given_data_wo_y, chain)
end
# ╔═╡ ac4f0eea-eada-48eb-914e-36fab79611b8
md"And then we can plot the marginal distribution for each observation."
# ╔═╡ 6a23b1e6-fd0f-406d-bc93-c713cecc8fe3
md"Observation number to plot: $(@bind post_pred_plt_i Slider(1:nobs))"
# ╔═╡ 039fd2fb-ab74-4d11-8144-e4264def99cf
if mcmc_linear.run
density(pred["y[$post_pred_plt_i]"], xlabel=latexstring("t_{" * string(post_pred_plt_i) * "}"), ylabel = "PDF", label=:none)
end
# ╔═╡ d9d67f4f-01db-453a-bf69-5454a432b5fd
md"""
### Testing sensitivity to prior
Based on what we've seen so far, it may seem that a PPL is primary syntactic sugar. Everything we've done so far could have been done reasonable some other way. So why are they useful?
PPLs can shine when you want to:
- Analyze data using a prior that makes the model non-linear,
- Analyze the data using a different model for the measurement errors,
- Test the sensitivity of your results to the choice of prior and/or noise model, or
- Use a model for which it would be really annoying to try to derive the log likelihood analytically, or
- Explore several variations on your model rapidly (talking about human time, not computer time).
For example, let's say we wanted to try a different prior for the orbital period. We could easily build a second model.
"""
# ╔═╡ a10430c3-ed36-4c04-9d81-aca325d46b1d
md"""
It looks like each of our parameters has converged. We can check our numerical estimates using `describe(chain)`, as below.
"""
# ╔═╡ 265123e6-f9f2-44f6-b1db-35f903ceaa9f
alt_period_prior = LogNormal(log(10), log10(10));
# ╔═╡ 63e72a21-24c3-410e-b8da-6c5abcfebb43
let
minx_plt, maxx_plt = 0, 100
plot(alt_period_prior, xlims=(minx_plt, maxx_plt), ylims=(0,maximum(pdf.(alt_period_prior,range(minx_plt,stop=maxx_plt, length=100)))), xlabel="Period (d)", ylabel="Prior PDF", label=:none)
end
# ╔═╡ 898cda4c-e193-4fdc-8139-7bb6ec858da0
@model function linear_regression_alt_prior(x, y, σ_y)
# Specify priors for model parameters
t0 ~ Uniform(0, 1200) # Time of 0th transit
period ~ alt_period_prior # Alternative prior for orbital period
# Specify likelihood
for i ∈ eachindex(y)
t_pred = t0 + period * x[i] # Predicted transit time given t0 and period
y[i] ~ Normal(t_pred, σ_y[i]) # Error model
end
end
# ╔═╡ 89fdecd6-57fd-4091-ac06-28edf04d0d01
model_given_data_alt_prior = linear_regression_alt_prior(df.n, df.t, df.σₜ)
# ╔═╡ 096a4447-3d01-4516-81c3-24ed876aca15
@bind mcmc_alt_prior confirm( PlutoUI.combine() do Child
md"""
I want to run MCMC sampler w/ alternative prior: $(Child("run", CheckBox()))
Samples from Markov chain: $(Child("num_iterations",NumberField(100:100:5000, default=100)))
"""
end )
# ╔═╡ 28311f3e-7921-4915-9751-150731d6d504
if mcmc_alt_prior.run
chain_alt_prior = sample(model_given_data_alt_prior, NUTS(0.65), mcmc_alt_prior.num_iterations, init_params=collect(mle_estimate.values))
end
# ╔═╡ 8f3eca15-a2f5-47f9-8f7e-9dadacb2f41a
if mcmc_linear.run && mcmc_alt_prior.run
density(chain[:,:period,1], label="Uniform prior")
density!(chain_alt_prior[:,:period,1], label="Alternative prior")
xlabel!("Period (d)")
ylabel!("PDF")
end
# ╔═╡ a45f383d-e80d-4d49-b3fc-f423609c3657
md"""
**Question:** Compare the marginal posteriors for orbital period. Are conclusions about the orbital period sensitive to the choice of a uniform prior or our alternative prior?
"""
# ╔═╡ e746194b-63dc-444e-92cc-a2dbecdd6d2f
md"""
### Sensitivity to error model
Similarly, we can easily swap out the likelihood used for the observations to make different assumptions for the distributions of observations measurements relative to the predicted transit time. In this case, we'll explore a model where we assume that each observation is affected by a combination of the reported measurement noise and an additional "jitter" which we'll model as i.i.d. Gaussian with unknown variance.
"""
# ╔═╡ 2e15c59a-d990-453f-baa5-19128573df02
@model function linear_regression_outliers(x, y, σ_y)
# Specify priors for model parameters
t0 ~ Uniform(0, 1200) # Time of 0th transit
period ~ alt_period_prior # Alternative prior for orbital period
# Specify liklihood
hour = 1/24
σ_jitter ~ LogNormal(hour, log(2)) # Prior for jitter
for i ∈ eachindex(y)
t_pred = t0 + period * x[i] # Predicted transit time given t0 and period
y[i] ~ Normal(t_pred, sqrt(σ_jitter^2+σ_y[i]^2))
end
end
# ╔═╡ 997dacbf-e0b1-4aac-977f-dd86180eb7dd
model_given_data_outliers = linear_regression_outliers(df.n, df.t, df.σₜ);
# ╔═╡ eea61c7a-8dde-4a00-8b67-1b0adda052cf
model_given_data_outliers
# ╔═╡ 09b185e3-a166-4168-81e4-2e9fb8a3132b
mle_estimate_outliers = optimize(model_given_data_outliers, MLE(), vcat(mle_estimate.values.array,(10/(24*60))) )
# ╔═╡ 48496dfa-3596-433b-91c4-77a6e3ed2ed1
@bind mcmc_outliers confirm( PlutoUI.combine() do Child
md"""
I want to run MCMC sampler w/ mixture model likelihood: $(Child("run", CheckBox()))
Samples from Markov chain: $(Child("num_iterations",NumberField(100:100:5000, default=100)))
"""
end )
# ╔═╡ 4eea70f3-04e7-4da6-bae9-f5cb76daa26c
if mcmc_outliers.run
ten_minutes = 10/(24*60)
chain_outliers = sample(model_given_data_outliers, NUTS(0.65), mcmc_outliers.num_iterations, init_params=mle_estimate_outliers.values.array)
end
# ╔═╡ d2fe1397-d717-404e-bbd1-74315aa2c079
if mcmc_outliers.run && mcmc_alt_prior.run
plt = plot()
density!(chain_alt_prior[:,:period,1], label="Reported uncertainties")
density!(chain_outliers[:,:period,1], label="Adding jitter term")
xlabel!("Period (d)")
ylabel!("PDF")
end
# ╔═╡ 041aad0e-52e8-4ca2-80b1-24863d129ae4
md"""
**Question:** Compare the marginal posteriors for orbital period. Are conclusions about the orbital period sensitive to the choice of whether to use only the reported measurement uncertainties or to allow for an additional source of "noise" causing the transit times to deviate from a linear model?
"""
# ╔═╡ d1564b23-fdb7-499a-bab4-05363e6e7f53
md"""
### Improving the model
Based on the previous analysis, it is clear that our original model was pretty good, but mathematically it is not a good description of the data at the level of ~10 minutes. Let's plot the residuals of the observed transit times relative to the posterior predictive distribution.
"""
# ╔═╡ 2144e594-1055-4a7a-9abc-88ef5d2f3045
if mcmc_linear.run
mean_posterior_predictive = vec(mean(Array(group(pred,:y)),dims=1));
scatter(df.n,(df.t.-mean_posterior_predictive).*24*60,yerr=df.σₜ.*24*60, label=:none)
xlabel!("Transit Number")
ylabel!("Residual (minutes)")
end
# ╔═╡ cd862907-3590-4b05-8715-797c2edae0bc
md"""
Ah ha! There's an additional signal. In this case, the transit times aren't strictly linear because of gravitational perturbations from to another planet in this planetary system.
A detailed model of n-body dynamics is computationally quite expensive. However, we can easily try a modeling the transit times as the sum of a linear emphemeris and an additional sinusoidal signal.
"""
# ╔═╡ f379a950-18f2-439f-8c36-53ce8e461247
# Bayesian linear regression.
@model function linear_plus_sinusoid(x, y, σ_y)
t0 ~ Uniform(0.0, 1200.0)
period ~ alt_period_prior
ttv_period ~ alt_period_prior
#ttv_t0 ~ Uniform(0.0, 1200.0)
ttv_amplitude_sin ~ Normal(0.0, 0.1)
ttv_amplitude_cos ~ Normal(0.0, 0.1)
mu0 = t0 .+ x .* period
mu = mu0 .+ ttv_amplitude_sin .* sin.((2π/ttv_period).*x) .+ ttv_amplitude_cos .* cos.((2π/ttv_period).*x)
y ~ MvNormal(mu, σ_y)
end
# ╔═╡ 78a2895d-b059-469a-b3a7-1bacf7248757
md"""
This model requires much longer Markov chains to converge, so you probably don't want to wait for a MCMC simulation long enough to make inferences from.
Nevertheless, this demonstrates the power of PPLs. It's easy to rapidly try out different assumptions and models.
"""
# ╔═╡ f8524ec7-32cc-4e39-a0b5-eadf5d9b2dd4
md"""
# Next Steps
## Additional Astronomical Applicaitons
As PPLs become more powerful, Astronomers have started making more use of them. For a few examples in the astronomical literature, see:
- [Buchner et al. (2015)](https://ui.adsabs.harvard.edu/abs/2015ApJ...802...89B/abstract)
- [Wolfgang et al. (2016)](https://ui.adsabs.harvard.edu/abs/2016ApJ...825...19W/abstract)
- [Hurley et al. (2017)](https://ui.adsabs.harvard.edu/abs/2017MNRAS.464..885H/abstract)
- [Mandel et al. (2019)](https://ui.adsabs.harvard.edu/abs/2019MNRAS.486.1086M/abstract)
"""
# ╔═╡ 7e7f1004-9c33-42f2-8b5f-15014e3d5c42
md"""## More Example Turing Models
The Turing manual has examples of how to implement several other common several other machine learning algorithms inside Turing. Here are just a few algorithms that you'll recognize from other lessons.
"""
# ╔═╡ e970ad2b-c75a-4e37-9f09-b1075fa183cf
md"""
### [Bayesian Logistic regression](https://turing.ml/dev/tutorials/02-logistic-regression/)
```julia
@model function logistic_regression(x, y, n, σ)
intercept ~ Normal(0, σ)
student ~ Normal(0, σ)
balance ~ Normal(0, σ)
income ~ Normal(0, σ)
for i in 1:n
v = logistic(intercept + student * x[i, 1] + balance * x[i, 2] + income * x[i, 3])
y[i] ~ Bernoulli(v)
end
end
```
"""
# ╔═╡ 73a2a248-1e68-4980-9797-0b5612047184
md"""
### [Probabilistic PCA](https://turing.ml/dev/tutorials/11-probabilistic-pca/)
```julia
@model function pPCA(x, ::Type{TV}=Array{Float64}) where {TV}
# Dimensionality of the problem.
N, D = size(x)
# latent variable z
z ~ filldist(Normal(), D, N)
# weights/loadings W
w ~ filldist(Normal(), D, D)
# mean offset
m ~ MvNormal(ones(D))
mu = (w * z .+ m)'
for d in 1:D
x[:, d] ~ MvNormal(mu[:, d], ones(N))
end
end
```
"""
# ╔═╡ 151e32ce-daeb-4127-8277-f4584d91a698
md"""
### [Bayesian Neural Network](https://turing.ml/dev/tutorials/03-bayesian-neural-network/)
```julia
# Construct a neural network using Flux
nn_initial = Chain(Dense(2, 3, tanh), Dense(3, 2, tanh), Dense(2, 1, σ))
# Extract weights and a helper function to reconstruct NN from weights
parameters_initial, reconstruct = Flux.destructure(nn_initial)
# Specify the probabilistic model.
@model function bayes_nn(xs, ts, nparameters, reconstruct)
# Create a regularization term and a Gaussian prior variance term.
alpha = 0.09
sig = sqrt(1.0 / alpha)
# Create the weight and bias vector.
parameters ~ MvNormal(zeros(nparameters), sig .* ones(nparameters))
# Construct NN from parameters
nn = reconstruct(parameters)
# Forward NN to make predictions
preds = nn(xs)
# Observe each prediction.
for i in 1:length(ts)
ts[i] ~ Bernoulli(preds[i])
end
end
# Perform inference.
N = 5000
ch = sample(
bayes_nn(hcat(xs...), ts, length(parameters_initial), reconstruct), HMC(0.05, 4), N
)
```
"""
# ╔═╡ a480bd7a-a4a9-43c7-81f5-77d15ec16289
md"""
# Setup & Helper Code
"""
# ╔═╡ d78db46d-1e20-4cd1-be53-81f635561b27
TableOfContents()
# ╔═╡ deb1a219-f33c-469c-98a9-5bab181e4a43
function aside(x)
@htl("""
<style>
@media (min-width: calc(700px + 30px + 300px)) {
aside.plutoui-aside-wrapper {
position: absolute;
right: -11px;
width: 0px;
}
aside.plutoui-aside-wrapper > div {
width: 300px;
}
}
</style>
<aside class="plutoui-aside-wrapper">
<div>
$(x)
</div>
</aside>
""")
end
# ╔═╡ 67ec0992-dd54-4172-b198-84bd61b7f48b
aside(md"""
!!! tip "Other PPLs"
- [STAN](https://mc-stan.org/) has interfaces for Julia, Python, R and the command line),
- [PyMC3](https://docs.pymc.io/en/v3/) and [numpyro](https://num.pyro.ai/en/stable/) are two of several options for python users,
- [Nimble](https://r-nimble.org/) for R users, and
- [Soss.jl](https://github.com/cscherrer/Soss.jl) is another option for Julia users, and
- many others (e.g., BUGS and JAGS were early PPLs but rarely used for new projects today).
!!! tip
STAN has a *great* [users guide](https://mc-stan.org/users/documentation/) that provides lots of good advice for Bayesian modeling regardless of how you do you computations.
""")
# ╔═╡ f93d7f0e-02b0-4935-9f5a-ab93ca28604b
aside(md"""
!!! tip "Tweaking Optimization Algorithm"
You likely got warning messages about convergence. The default results are still good enough for our purposes. If you wanted to dig deeper, the [Turing.jl user guide](https://turing.ml/dev/docs/using-turing/guide#maximum-likelihood-and-maximum-a-posterior-estimates) shows how you can choose your optimization algorithm and pass optional configuration parameters to improve the rate and chances of convergence.
""")
# ╔═╡ bc606b9a-0ae9-4517-9262-091ec59a8bf6
if false # to create datafile from space delimited file
lines = readlines("koi250.txt")
df1 = DataFrame(map(l->(;n=parse(Int,l[9:12]), t_no_ttv=parse(Float64,l[14:24]), Δt=parse(Float64,l[26:35]), σₜ=parse(Float64,l[39:43])), lines[1:end-1]))
df1.t = df1.t_no_ttv .+ df1.Δt./(24*60)
CSV.write("koi250.01.csv", df1[!, [:n, :t, :σₜ, :t_no_ttv, :Δt]])
end;
# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"
PairPlots = "43a3c2be-4208-490b-832a-a21dcd55d7da"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
[compat]
CSV = "~0.10.4"
ColorSchemes = "~3.18.0"
DataFrames = "~1.3.4"
Distributions = "~0.25.58"
ForwardDiff = "~0.10.29"
HypertextLiteral = "~0.9.4"
LaTeXStrings = "~1.3.0"
MCMCChains = "~5.3.0"
Optim = "~1.7.0"
PDMats = "~0.11.10"
PairPlots = "~0.5.4"
Plots = "~1.29.0"
PlutoUI = "~0.7.38"
StatsPlots = "~0.14.34"
Turing = "~0.21.1"
"""
# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised
julia_version = "1.7.0"
manifest_format = "2.0"
[[deps.AbstractFFTs]]
deps = ["ChainRulesCore", "LinearAlgebra"]
git-tree-sha1 = "6f1d9bc1c08f9f4a8fa92e3ea3cb50153a1b40d4"
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
version = "1.1.0"
[[deps.AbstractMCMC]]
deps = ["BangBang", "ConsoleProgressMonitor", "Distributed", "Logging", "LoggingExtras", "ProgressLogging", "Random", "StatsBase", "TerminalLoggers", "Transducers"]
git-tree-sha1 = "47aca4cf0dc430f20f68f6992dc4af0e4dc8ebee"
uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
version = "4.0.0"
[[deps.AbstractPPL]]
deps = ["AbstractMCMC", "DensityInterface", "Setfield", "SparseArrays"]
git-tree-sha1 = "6320752437e9fbf49639a410017d862ad64415a5"
uuid = "7a57a42e-76ec-4ea3-a279-07e840d6d9cf"
version = "0.5.2"
[[deps.AbstractPlutoDingetjes]]
deps = ["Pkg"]
git-tree-sha1 = "8eaf9f1b4921132a4cff3f36a1d9ba923b14a481"
uuid = "6e696c72-6542-2067-7265-42206c756150"
version = "1.1.4"
[[deps.AbstractTrees]]
git-tree-sha1 = "03e0550477d86222521d254b741d470ba17ea0b5"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.3.4"
[[deps.Adapt]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "af92965fb30777147966f58acb05da51c5616b5f"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "3.3.3"
[[deps.AdvancedHMC]]
deps = ["AbstractMCMC", "ArgCheck", "DocStringExtensions", "InplaceOps", "LinearAlgebra", "ProgressMeter", "Random", "Requires", "Setfield", "Statistics", "StatsBase", "StatsFuns", "UnPack"]
git-tree-sha1 = "345effa84030f273ee86fcdd706d8484ce9a1a3c"
uuid = "0bf59076-c3b1-5ca4-86bd-e02cd72cde3d"
version = "0.3.5"
[[deps.AdvancedMH]]
deps = ["AbstractMCMC", "Distributions", "Random", "Requires"]
git-tree-sha1 = "5d9e09a242d4cf222080398468244389c3428ed1"
uuid = "5b7e9947-ddc0-4b3f-9b55-0d8042f74170"
version = "0.6.7"
[[deps.AdvancedPS]]
deps = ["AbstractMCMC", "Distributions", "Libtask", "Random", "StatsFuns"]
git-tree-sha1 = "9ff1247be1e2aa2e740e84e8c18652bd9d55df22"
uuid = "576499cb-2369-40b2-a588-c64705576edc"
version = "0.3.8"
[[deps.AdvancedVI]]
deps = ["Bijectors", "Distributions", "DistributionsAD", "DocStringExtensions", "ForwardDiff", "LinearAlgebra", "ProgressMeter", "Random", "Requires", "StatsBase", "StatsFuns", "Tracker"]
git-tree-sha1 = "e743af305716a527cdb3a67b31a33a7c3832c41f"
uuid = "b5ca4192-6429-45e5-a2d9-87aec30a685c"
version = "0.1.5"
[[deps.ArgCheck]]
git-tree-sha1 = "a3a402a35a2f7e0b87828ccabbd5ebfbebe356b4"
uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197"
version = "2.3.0"
[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
[[deps.Arpack]]
deps = ["Arpack_jll", "Libdl", "LinearAlgebra", "Logging"]
git-tree-sha1 = "91ca22c4b8437da89b030f08d71db55a379ce958"
uuid = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
version = "0.5.3"
[[deps.Arpack_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "OpenBLAS_jll", "Pkg"]
git-tree-sha1 = "5ba6c757e8feccf03a1554dfaf3e26b3cfc7fd5e"
uuid = "68821587-b530-5797-8361-c406ea357684"
version = "3.5.1+1"
[[deps.ArrayInterface]]
deps = ["Compat", "IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"]
git-tree-sha1 = "81f0cb60dc994ca17f68d9fb7c942a5ae70d9ee4"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "5.0.8"
[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[deps.AxisAlgorithms]]
deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"]
git-tree-sha1 = "66771c8d21c8ff5e3a93379480a2307ac36863f7"
uuid = "13072b0f-2c55-5437-9ae7-d433b7a33950"
version = "1.0.1"
[[deps.AxisArrays]]
deps = ["Dates", "IntervalSets", "IterTools", "RangeArrays"]
git-tree-sha1 = "cf6875678085aed97f52bfc493baaebeb6d40bcb"
uuid = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
version = "0.4.5"
[[deps.BangBang]]
deps = ["Compat", "ConstructionBase", "Future", "InitialValues", "LinearAlgebra", "Requires", "Setfield", "Tables", "ZygoteRules"]
git-tree-sha1 = "b15a6bc52594f5e4a3b825858d1089618871bf9d"
uuid = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
version = "0.3.36"
[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[deps.Baselet]]
git-tree-sha1 = "aebf55e6d7795e02ca500a689d326ac979aaf89e"
uuid = "9718e550-a3fa-408a-8086-8db961cd8217"
version = "0.1.1"
[[deps.Bijectors]]
deps = ["ArgCheck", "ChainRulesCore", "ChangesOfVariables", "Compat", "Distributions", "Functors", "InverseFunctions", "IrrationalConstants", "LinearAlgebra", "LogExpFunctions", "MappedArrays", "Random", "Reexport", "Requires", "Roots", "SparseArrays", "Statistics"]
git-tree-sha1 = "a83abdc57f892576bf1894d558e8a5c35505cdb1"
uuid = "76274a88-744f-5084-9051-94815aaf08c4"
version = "0.10.1"
[[deps.Bzip2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "19a35467a82e236ff51bc17a3a44b69ef35185a2"
uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
version = "1.0.8+0"
[[deps.CEnum]]
git-tree-sha1 = "eb4cb44a499229b3b8426dcfb5dd85333951ff90"
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
version = "0.4.2"
[[deps.CSV]]
deps = ["CodecZlib", "Dates", "FilePathsBase", "InlineStrings", "Mmap", "Parsers", "PooledArrays", "SentinelArrays", "Tables", "Unicode", "WeakRefStrings"]
git-tree-sha1 = "873fb188a4b9d76549b81465b1f75c82aaf59238"
uuid = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
version = "0.10.4"
[[deps.Cairo_jll]]
deps = ["Artifacts", "Bzip2_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"]
git-tree-sha1 = "4b859a208b2397a7a623a03449e4636bdb17bcf2"
uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a"
version = "1.16.1+1"
[[deps.Calculus]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "f641eb0a4f00c343bbc32346e1217b86f3ce9dad"
uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9"
version = "0.5.1"
[[deps.ChainRules]]
deps = ["ChainRulesCore", "Compat", "IrrationalConstants", "LinearAlgebra", "Random", "RealDot", "SparseArrays", "Statistics"]
git-tree-sha1 = "de68815ccf15c7d3e3e3338f0bd3a8a0528f9b9f"
uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2"
version = "1.33.0"
[[deps.ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "9950387274246d08af38f6eef8cb5480862a435f"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.14.0"
[[deps.ChangesOfVariables]]
deps = ["ChainRulesCore", "LinearAlgebra", "Test"]
git-tree-sha1 = "1e315e3f4b0b7ce40feded39c73049692126cf53"
uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
version = "0.1.3"
[[deps.Clustering]]
deps = ["Distances", "LinearAlgebra", "NearestNeighbors", "Printf", "SparseArrays", "Statistics", "StatsBase"]
git-tree-sha1 = "75479b7df4167267d75294d14b58244695beb2ac"
uuid = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
version = "0.14.2"
[[deps.CodeInfoTools]]
git-tree-sha1 = "91018794af6e76d2d42b96b25f5479bca52598f5"
uuid = "bc773b8a-8374-437a-b9f2-0e9785855863"
version = "0.3.5"
[[deps.CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
git-tree-sha1 = "ded953804d019afa9a3f98981d99b33e3db7b6da"
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
version = "0.7.0"
[[deps.ColorSchemes]]
deps = ["ColorTypes", "ColorVectorSpace", "Colors", "FixedPointNumbers", "Random"]
git-tree-sha1 = "7297381ccb5df764549818d9a7d57e45f1057d30"
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
version = "3.18.0"
[[deps.ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
git-tree-sha1 = "a985dc37e357a3b22b260a5def99f3530fb415d3"
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
version = "0.11.2"
[[deps.ColorVectorSpace]]
deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "SpecialFunctions", "Statistics", "TensorCore"]
git-tree-sha1 = "3f1f500312161f1ae067abe07d13b40f78f32e07"
uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4"
version = "0.9.8"
[[deps.Colors]]
deps = ["ColorTypes", "FixedPointNumbers", "Reexport"]
git-tree-sha1 = "417b0ed7b8b838aa6ca0a87aadf1bb9eb111ce40"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.12.8"
[[deps.Combinatorics]]
git-tree-sha1 = "08c8b6831dc00bfea825826be0bc8336fc369860"
uuid = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
version = "1.0.2"
[[deps.CommonSolve]]
git-tree-sha1 = "68a0743f578349ada8bc911a5cbd5a2ef6ed6d1f"
uuid = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
version = "0.2.0"
[[deps.CommonSubexpressions]]
deps = ["MacroTools", "Test"]
git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7"
uuid = "bbf7d656-a473-5ed7-a52c-81e309532950"
version = "0.3.0"
[[deps.Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "b153278a25dd42c65abbf4e62344f9d22e59191b"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.43.0"
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
[[deps.CompositionsBase]]
git-tree-sha1 = "455419f7e328a1a2493cabc6428d79e951349769"
uuid = "a33af91c-f02d-484b-be07-31d278c5ca2b"
version = "0.1.1"
[[deps.ConsoleProgressMonitor]]
deps = ["Logging", "ProgressMeter"]
git-tree-sha1 = "3ab7b2136722890b9af903859afcf457fa3059e8"
uuid = "88cd18e8-d9cc-4ea6-8889-5259c0d15c8b"
version = "0.1.2"
[[deps.ConstructionBase]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "f74e9d5388b8620b4cee35d4c5a618dd4dc547f4"
uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
version = "1.3.0"
[[deps.Contour]]
deps = ["StaticArrays"]
git-tree-sha1 = "9f02045d934dc030edad45944ea80dbd1f0ebea7"
uuid = "d38c429a-6771-53c6-b99e-75d170b6e991"
version = "0.5.7"
[[deps.Crayons]]
git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "4.1.1"
[[deps.DataAPI]]
git-tree-sha1 = "fb5f5316dd3fd4c5e7c30a24d50643b73e37cd40"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.10.0"
[[deps.DataFrames]]
deps = ["Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrettyTables", "Printf", "REPL", "Reexport", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "daa21eb85147f72e41f6352a57fccea377e310a9"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "1.3.4"
[[deps.DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "cc1a8e22627f33c789ab60b36a9132ac050bbf75"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.18.12"
[[deps.DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"
[[deps.DataValues]]
deps = ["DataValueInterfaces", "Dates"]
git-tree-sha1 = "d88a19299eba280a6d062e135a43f00323ae70bf"
uuid = "e7dc6d0d-1eca-5fa6-8ad6-5aecde8b7ea5"
version = "0.4.13"
[[deps.Dates]]