1+ import breeze .stats .distributions .Gaussian
12import io .github .mandar2812 .dynaml .kernels .{MAKernel , RBFCovFunc }
23import io .github .mandar2812 .dynaml .models .bayes .LinearTrendGaussianPrior
34import io .github .mandar2812 .dynaml .probability .MultGaussianPRV
45import io .github .mandar2812 .dynaml .analysis .implicits ._
56import com .quantifind .charts .Highcharts ._
67
78
8- val rbfc = new RBFCovFunc (1.0 )
9- val n = new MAKernel (0.1 )
9+ val rbfc = new RBFCovFunc (0.5 )
10+ val n = new MAKernel (0.5 )
1011
11- val gp_prior = new LinearTrendGaussianPrior [Double ](rbfc, n, 0.5 )
12+ val gp_prior = new LinearTrendGaussianPrior [Double ](rbfc, n, 0.0 )
1213
1314val xs = Seq .tabulate[Double ](20 )(0.5 * _)
1415
@@ -20,3 +21,17 @@ spline(xs, samples.head)
2021hold()
2122samples.tail.foreach((s : Seq [Double ]) => spline(xs, s))
2223unhold()
24+
25+ val noiseAdd = new Gaussian (0.0 , 0.1 )
26+
27+ val dataset = Seq ((- 0.1 , 2.5 + noiseAdd.draw()), (10.51 , 1.2 + noiseAdd.draw()))
28+
29+ val gpModel = gp_prior.posteriorModel(dataset)
30+ val zs : MultGaussianPRV = gpModel.predictiveDistribution(xs)
31+
32+ val samplesPost = zs.iid(8 ).sample().map(s => s.toBreezeVector.toArray.toSeq)
33+
34+ spline(xs, samplesPost.head)
35+ hold()
36+ samplesPost.tail.foreach((s : Seq [Double ]) => spline(xs, s))
37+ unhold()
0 commit comments