File:Gaussianprocess.gif

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Gaussianprocess.gif(667 × 292 pixels, file size: 961 KB, MIME type: image/gif, looped, 49 frames, 4.9 s)

Summary

Description
English: If you have some data and instead of fitting a model you want to estimate the reasonable shapes any smooth enough function compatible with them can take, you can look at the envelope of the random walks passing through the data.
Date
Source https://twitter.com/j_bertolotti/status/1249341481057468417
Author Jacopo Bertolotti
Permission
(Reusing this file)
https://twitter.com/j_bertolotti/status/1030470604418428929

Mathematica 12.0 code

data = {0 -> 0, 50 -> 3, 100 -> 10, 150 -> 5};
p = Predict[data, Method -> {"GaussianProcess", "CovarianceType" -> "SquaredExponential"}];
rw = Accumulate /@ 
   RandomVariate[NormalDistribution[0, 0.5], {1000, 50}];
pos1 = Flatten[Position[rw[[All, -2]], # ] & /@ Select[rw[[All, -2]], Abs[# - 3] < 1 &] ];
pos2 = Flatten[Position[rw[[All, -2]], # ] & /@ Select[rw[[All, -2]], Abs[# - 7] < 1 &] ];
pos3 = Flatten[Position[rw[[All, -2]], # ] & /@ Select[rw[[All, -2]], Abs[# + 5] < 1 &] ];
n = Dimensions[pos2][[1]]
p0 = Table[
   Legended[Show[ListPlot[rw[[pos1]][[1 ;; n, 1 ;; Max[3, t] ]], Joined -> True, PlotStyle -> Directive[Black, Opacity[0.2]], DataRange -> {0.9, Max[3, t]} ]
     ,
     ListPlot[List @@@ data, PlotStyle -> Directive[Purple, PointSize[0.03]] ]
     , PlotRange -> {{0, 160}, {-10, 20}}
     ]
    , Column[{LineLegend[{Purple}, {"Prediction"}], LineLegend[{Orange}, {"Credible Interval"}], PointLegend[{Purple}, {"Data"}]}]
    ]
   , {t, 0, 50, 5}];
p1 = Table[
   Legended[Show[ListPlot[rw[[pos1]][[1 ;; n ]], Joined -> True, PlotStyle -> Directive[Black, Opacity[0.2]], DataRange -> {0.9, 50} ]
     ,
     ListPlot[rw[[pos2]][[All, 1 ;; Max[3, t]]] + 3, Joined -> True, PlotStyle -> Directive[Black, Opacity[0.2]], DataRange -> {51, 51 + Max[3, t]} ]
     ,
     ListPlot[List @@@ data, PlotStyle -> Directive[Purple, PointSize[0.03]] ], PlotRange -> {{0, 160}, {-10, 20}}
     ]
    , Column[{LineLegend[{Purple}, {"Prediction"}], LineLegend[{Orange}, {"Credible Interval"}], PointLegend[{Purple}, {"Data"}]}]
    ]
   , {t, 0, 50, 5}];
p2 = Table[
   Legended[Show[
     ListPlot[rw[[pos1]][[1 ;; n ]], Joined -> True, PlotStyle -> Directive[Black, Opacity[0.2]], DataRange -> {0.9, 50} ]
     ,
     ListPlot[rw[[pos2]] + 3, Joined -> True, PlotStyle -> Directive[Black, Opacity[0.2]], DataRange -> {51, 100} ]
     ,
     ListPlot[rw[[pos3]][[1 ;; n, 1 ;; Max[3, t]]] + 10, Joined -> True, PlotStyle -> Directive[Black, Opacity[0.2]], DataRange -> {101, 101 + Max[3, t]} ]
     ,
     ListPlot[List @@@ data, PlotStyle -> Directive[Purple, PointSize[0.03]] ], PlotRange -> {{0, 160}, {-10, 20}}
     ]
    , Column[{LineLegend[{Purple}, {"Prediction"}], LineLegend[{Orange}, {"Credible Interval"}], PointLegend[{Purple}, {"Data"}]}]
    ]
   , {t, 0, 50, 5}];
p3 = Table[
   Legended[Show[
     ListPlot[rw[[pos1]][[1 ;; 35 ]], Joined -> True, PlotStyle -> Directive[Black, Opacity[0.2]], DataRange -> {0.9, 50} ]
     ,
     ListPlot[rw[[pos2]] + 3, Joined -> True, PlotStyle -> Directive[Black, Opacity[0.2]], DataRange -> {51, 100} ]
     ,
     ListPlot[rw[[pos3]][[1 ;; 35]] + 10, Joined -> True, PlotStyle -> Directive[Black, Opacity[0.2]], DataRange -> {101, 150} ]
     ,
     Plot[{p[x], p[x] + StandardDeviation[p[x, "Distribution"]], p[x] - StandardDeviation[p[x, "Distribution"]]}, {x, -1, 150}, PlotStyle -> {Directive[Purple, Opacity[t]], Directive[Orange, Opacity[t]], Directive[Orange, Opacity[t]]}, Filling -> {2 -> {3}}, FillingStyle -> Opacity[t/3], Exclusions -> False, PerformanceGoal -> "Speed"]
     ,
     ListPlot[List @@@ data, PlotStyle -> Directive[Purple, PointSize[0.03]] ], PlotRange -> {{0, 160}, {-10, 20}}
     ]
    , Column[{LineLegend[{Purple}, {"Prediction"}], LineLegend[{Orange}, {"Credible Interval"}], PointLegend[{Purple}, {"Data"}]}]
    ]
   , {t, 0, 1, 0.2}];
ListAnimate[p3]
ListAnimate[Join[p0, p1, p2, p3, Table[p3[[-1]], {10}]] ]

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Captions

Gaussian Process Regression as the envelope of random walks.

12 April 2020

image/gif

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current10:12, 13 April 2020Thumbnail for version as of 10:12, 13 April 2020667 × 292 (961 KB)BertoUploaded own work with UploadWizard
The following pages on the English Wikipedia use this file (pages on other projects are not listed):

Global file usage

The following other wikis use this file:

Metadata