|
| 1 | +package io.github.mandar2812.dynaml.modelpipe |
| 2 | + |
| 3 | +import breeze.linalg.{DenseMatrix, DenseVector} |
| 4 | +import breeze.stats.distributions.{ContinuousDistr, Moments} |
| 5 | +import io.github.mandar2812.dynaml.algebra.{PartitionedPSDMatrix, PartitionedVector} |
| 6 | +import io.github.mandar2812.dynaml.models.gp.AbstractGPRegressionModel |
| 7 | +import io.github.mandar2812.dynaml.models.stp.AbstractSTPRegressionModel |
| 8 | +import io.github.mandar2812.dynaml.models.{ContinuousProcessModel, GenContinuousMixtureModel, SecondOrderProcessModel, StochasticProcessMixtureModel} |
| 9 | +import io.github.mandar2812.dynaml.optimization.GloballyOptimizable |
| 10 | +import io.github.mandar2812.dynaml.pipes.DataPipe2 |
| 11 | +import io.github.mandar2812.dynaml.probability.{ContinuousRVWithDistr, MultGaussianPRV, MultStudentsTPRV} |
| 12 | +import io.github.mandar2812.dynaml.probability.distributions.{BlockedMultiVariateGaussian, BlockedMultivariateStudentsT, HasErrorBars} |
| 13 | + |
| 14 | +import scala.reflect.ClassTag |
| 15 | + |
| 16 | +/** |
| 17 | + * Mixture Pipe takes a sequence of stochastic process models |
| 18 | + * and associated probability weights and returns a mixture model. |
| 19 | + * @author mandar2812 date 22/06/2017. |
| 20 | + * */ |
| 21 | +abstract class MixturePipe[ |
| 22 | +T, I: ClassTag, Y, YDomain, YDomainVar, |
| 23 | +BaseDistr <: ContinuousDistr[YDomain] |
| 24 | + with Moments[YDomain, YDomainVar] |
| 25 | + with HasErrorBars[YDomain], |
| 26 | +W1 <: ContinuousRVWithDistr[YDomain, BaseDistr], |
| 27 | +BaseProcess <: ContinuousProcessModel[T, I, Y, W1] |
| 28 | + with SecondOrderProcessModel[T, I, Y, Double, DenseMatrix[Double], W1] |
| 29 | + with GloballyOptimizable] extends |
| 30 | + DataPipe2[Seq[BaseProcess], DenseVector[Double], |
| 31 | + GenContinuousMixtureModel[ |
| 32 | + T, I, Y, YDomain, YDomainVar, |
| 33 | + BaseDistr, W1, BaseProcess]] |
| 34 | + |
| 35 | + |
| 36 | +class GPMixturePipe[T, I: ClassTag] extends |
| 37 | + MixturePipe[T, I, Double, PartitionedVector, PartitionedPSDMatrix, |
| 38 | + BlockedMultiVariateGaussian, MultGaussianPRV, |
| 39 | + AbstractGPRegressionModel[T, I]] { |
| 40 | + |
| 41 | + override def run( |
| 42 | + models: Seq[AbstractGPRegressionModel[T, I]], |
| 43 | + weights: DenseVector[Double]) = |
| 44 | + StochasticProcessMixtureModel(models, weights) |
| 45 | +} |
| 46 | + |
| 47 | +class StudentTMixturePipe[T, I: ClassTag] extends |
| 48 | + MixturePipe[T, I, Double, PartitionedVector, PartitionedPSDMatrix, |
| 49 | + BlockedMultivariateStudentsT, MultStudentsTPRV, |
| 50 | + AbstractSTPRegressionModel[T, I]] { |
| 51 | + |
| 52 | + override def run( |
| 53 | + models: Seq[AbstractSTPRegressionModel[T, I]], |
| 54 | + weights: DenseVector[Double]) = |
| 55 | + StochasticProcessMixtureModel(models, weights) |
| 56 | +} |
0 commit comments