Skip to content

Commit 9df65cf

Browse files
committed
Mods to stochastic priors script
1 parent 7878329 commit 9df65cf

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

scripts/stochasticPriors.scala

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
import breeze.stats.distributions.Gaussian
12
import io.github.mandar2812.dynaml.kernels.{MAKernel, RBFCovFunc}
23
import io.github.mandar2812.dynaml.models.bayes.LinearTrendGaussianPrior
34
import io.github.mandar2812.dynaml.probability.MultGaussianPRV
45
import io.github.mandar2812.dynaml.analysis.implicits._
56
import 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

1314
val xs = Seq.tabulate[Double](20)(0.5*_)
1415

@@ -20,3 +21,17 @@ spline(xs, samples.head)
2021
hold()
2122
samples.tail.foreach((s: Seq[Double]) => spline(xs, s))
2223
unhold()
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

Comments
 (0)