Mercurial > hg > jslab
view src/samer/units/NoisyLinearSource.java @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | bf79fb79ee13 |
children |
line wrap: on
line source
/* * Copyright (c) 2000, Samer Abdallah, King's College London. * All rights reserved. * * This software is provided AS iS and WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. */ package samer.units; import samer.core.*; import samer.maths.*; import samer.tools.*; /** A class for generating random vectors according to a particular generative model. If the output is y, then y = Bx + e where x is a vector of indepedent identitically distributed random variables, e is another vector of iid random variables, and B is an arbitrary matrix. The elements of x are the 'sources' and are drawn from the random number generator rnd. The elements of e are the 'noise' and are drawn from a different generator, which defaults to Gaussian. */ public class NoisyLinearSource extends AnonymousTask { public VGenerator src, noise; VVector s; // sources VVector x; // mixtures VVector e; // noise Matrix A; // mixing matrix double [] xa, ea; Task t1, t2; public NoisyLinearSource( int m, int n) throws Exception { // super("source"); // Shell.push(node); s = new VVector("s",m); x = new VVector("x",n); e = new VVector("e",n); A = new Matrix("A",n,m); A.identity(); src = new VGenerator("source"); noise = new VGenerator("noise"); // Shell.pop(); xa=s.array(); ea=e.array(); t1 = new MatrixTimesVector(x,A,s); t2 = new VectorPlusEqualsVector(x,e); } public VVector output() { return x; } public Matrix getMixingMatrix() { return A; } public void run() throws Exception { src.next(xa); noise.next(ea); t1.run(); t2.run(); s.changed(); x.changed(); e.changed(); } public void dispose() { src.dispose(); noise.dispose(); s.dispose(); x.dispose(); e.dispose(); A.dispose(); t1.dispose(); t2.dispose(); super.dispose(); } }