Example usage for org.apache.commons.math3.linear RealVector outerProduct

List of usage examples for org.apache.commons.math3.linear RealVector outerProduct

Introduction

In this page you can find the example usage for org.apache.commons.math3.linear RealVector outerProduct.

Prototype

public RealMatrix outerProduct(RealVector v) 

Source Link

Document

Compute the outer product.

Usage

From source file:org.rhwlab.variationalbayesian.SuperVoxelGaussianMixture.java

public void Mstep() {
    lnPi();//  w  w w. j av  a2s  .  c o m
    alphaBetaNuLambda();
    // compute the means of the components
    for (int k = 0; k < K; ++k) {
        RealVector v1 = xBar[k].mapMultiply(N[k]);
        RealVector v2 = mu0.mapMultiply(beta0);
        RealVector v3 = v2.add(v1);
        m[k] = v3.mapDivide(beta[k]);
    }

    // compute the precision matrices
    for (int k = 0; k < K; ++k) {
        RealVector del = xBar[k].subtract(mu0);
        RealMatrix del2 = del.outerProduct(del);
        double f = beta0 * N[k] / (beta0 + N[k]);
        RealMatrix mat = del2.scalarMultiply(f);
        RealMatrix NS = S[k].scalarMultiply(N[k]);
        RealMatrix Winverse = W0inverse.add(NS).add(mat);
        LUDecomposition cd = new LUDecomposition(Winverse);
        W[k] = cd.getSolver().getInverse();
        detW[k] = 1.0 / cd.getDeterminant();
        int auiosdfu = 0;
    }
}