mpv2
Class DictionaryLearning

java.lang.Object
  extended by mpv2.DictionaryLearning

public class DictionaryLearning
extends java.lang.Object


Field Summary
static int BMP
           
static int OMP
           
static int ORMP
           
static int PS
           
 
Constructor Summary
DictionaryLearning(AllMatrices D0, boolean useDD)
           
DictionaryLearning(AllMatrices D0, boolean useDD, int verb)
          Instantiate an object of this class by giving initial dictionary.
 
Method Summary
 SimpleMatrix getDictionary()
           
 int[] getIndexW()
           
 SymmetricMatrix getInnerProductMatrix()
           
 double getLambda()
          Calculate and return lambda, the forgetting factor.
 double getLambda(double x)
          Calculate and return lambda, the forgetting factor.
 int getMPMet()
           
 int getNoTV()
           
 double[] getResidual()
           
 double[] getSnrTab()
           
 double[] getSumAllrrTab()
           
 double[] getSumAllwwTab()
           
 double[] getSumAllxxTab()
           
 double getSumrr()
           
 double[] getSumrrTab()
           
 double getSumww()
           
 double[] getSumwwTab()
           
 double getSumxx()
           
 double[] getSumxxTab()
           
 SymmetricMatrix getTheCMatrix()
           
 double[] getValueW()
           
 double[] getWeights()
           
 void ilsdla(double[] data, int noi)
          ILS-DLA, prosess several training vectors by Iterative Least Squares, ILS-DLA.
 void rlsdla(double[] data, int noi)
          RLS-DLA, prosess several training vectors by RLS-DLA.
 void rlsdla1(double[] x)
          RLS-DLA-1 Prosess a single training vector, one iteration of RLS-DLA.
 void setBMP()
           
 void setBMP(int s)
          Set the Matching Pursuit Method to BMP and parameters to use.
 void setLambda(char lamMet, double lamLow, double lamHigh, double lamPar)
          Set how to calculate the class variable lambda, the forgetting factor.
 void setLoggOff()
           
 void setLoggOn()
           
 void setOMP()
           
 void setOMP(int s, double rel, double abs)
          Set the Matching Pursuit Method to OMP and parameters to use.
 void setORMP()
           
 void setORMP(int s, double rel, double abs)
          Set the Matching Pursuit Method to ORMP and parameters to use.
 void setPS()
           
 void setPS(int s, double rel, double abs, int noc)
          Set the Matching Pursuit Method to Partial Search and parameters to use.
 void setVerbose(int verb)
          Set verbose and veryVerbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BMP

public static final int BMP
See Also:
Constant Field Values

OMP

public static final int OMP
See Also:
Constant Field Values

ORMP

public static final int ORMP
See Also:
Constant Field Values

PS

public static final int PS
See Also:
Constant Field Values
Constructor Detail

DictionaryLearning

public DictionaryLearning(AllMatrices D0,
                          boolean useDD,
                          int verb)
Instantiate an object of this class by giving initial dictionary. The initial dictionary, D0, is normalized and copied. D0 is counted as the first K training vectors, thus it is best to use K training vectors as D0. These training vectors should not be normalized unless the rest of the training vectors are normalized too. Training should then start with the next vector. If the vectors used for D0 are also wanted as training vectors, they should NOT be among the first ones to be used. The size of D0 set the size of D, NxK, the length of a training vector should then be N, and number of elements (atoms) in the dictionary is K.

Parameters:
D0 - The initial dictionary,
useDD - a boolean to tell if the matrix of innerproduct is to be used, (Matlab: DD = D'*D).
verb - verbose level, default is 0
Throws:
java.lang.IllegalArgumentException - Supplied data is too small

DictionaryLearning

public DictionaryLearning(AllMatrices D0,
                          boolean useDD)
Method Detail

getDictionary

public SimpleMatrix getDictionary()

getInnerProductMatrix

public SymmetricMatrix getInnerProductMatrix()

getTheCMatrix

public SymmetricMatrix getTheCMatrix()

getWeights

public double[] getWeights()

getResidual

public double[] getResidual()

getNoTV

public int getNoTV()

getMPMet

public int getMPMet()

getSumxx

public double getSumxx()

getSumww

public double getSumww()

getSumrr

public double getSumrr()

getSumAllxxTab

public double[] getSumAllxxTab()

getSumAllwwTab

public double[] getSumAllwwTab()

getSumAllrrTab

public double[] getSumAllrrTab()

getSnrTab

public double[] getSnrTab()

getSumxxTab

public double[] getSumxxTab()

getSumwwTab

public double[] getSumwwTab()

getSumrrTab

public double[] getSumrrTab()

getIndexW

public int[] getIndexW()

getValueW

public double[] getValueW()

getLambda

public double getLambda()
Calculate and return lambda, the forgetting factor. The value is based on noTV (number of Training Vectors processed) and the class variables which set the method to use.

Returns:
lambda

getLambda

public double getLambda(double x)
Calculate and return lambda, the forgetting factor.

Parameters:
x - a double which usually is (noTV/lambdaPar)
Returns:
lambda

setLambda

public void setLambda(char lamMet,
                      double lamLow,
                      double lamHigh,
                      double lamPar)
Set how to calculate the class variable lambda, the forgetting factor. The first argument set the method, which are 'L' linear, 'Q' quadratic, 'C' cubic, 'H' hyperbola, and 'E' exponential. And a special variant '1' for the constant value of 1 all the time. The next two arguments are low and high value for lambda. To use lambda as a constant, set the method to 'L' and low and high equal. The fourth argument set how many training vectors to use before getting to the high value (for 'L', 'Q' and 'C'), or before getting to a value in the middle between low and high (for 'H' and 'E')

Parameters:
lamMet - 'L' linear, 'Q' quadratic, 'C' cubic, 'H' hyperbola, and 'E' exponential or '1'
lamLow - lower value for lambda
lamHigh - higher value for lambda
lamPar - parameter 'a' for method, usually a quite large number
Throws:
java.lang.IllegalArgumentException

setBMP

public void setBMP()

setOMP

public void setOMP()

setORMP

public void setORMP()

setPS

public void setPS()

setBMP

public void setBMP(int s)
Set the Matching Pursuit Method to BMP and parameters to use. Realtive or absolute error is not available for BMP yet.

Parameters:
s - max number of non-zeros to use in MP

setOMP

public void setOMP(int s,
                   double rel,
                   double abs)
Set the Matching Pursuit Method to OMP and parameters to use. default for rel and abs is for both 1.0e-6, for s default is 2

Parameters:
s - max number of non-zeros to use in MP. End MP when non-zeros in w == s
rel - max relative error to use in MP. End MP when ||r|| < rel*||x||
abs - max absolute error to use in MP. End MP when ||r|| < abs

setORMP

public void setORMP(int s,
                    double rel,
                    double abs)
Set the Matching Pursuit Method to ORMP and parameters to use. default for rel and abs is for both 1.0e-6, for s default is 2

Parameters:
s - max number of non-zeros to use in MP. End MP when non-zeros in w == s
rel - max relative error to use in MP. End MP when ||r|| < rel*||x||
abs - max absolute error to use in MP. End MP when ||r|| < abs

setPS

public void setPS(int s,
                  double rel,
                  double abs,
                  int noc)
Set the Matching Pursuit Method to Partial Search and parameters to use. default for rel and abs is for both 1.0e-6, for s default is 2

Parameters:
s - max number of non-zeros to use in MP. End MP when non-zeros in w == s
rel - max relative error to use in MP. End MP when ||r|| < rel*||x||
abs - max absolute error to use in MP. End MP when ||r|| < abs
noc - number of combinations to search, typically in range 5-200

setLoggOn

public void setLoggOn()

setLoggOff

public void setLoggOff()

setVerbose

public void setVerbose(int verb)
Set verbose and veryVerbose

Parameters:
verb - 0 for both false, 1 only verbose true, 2 both true
Throws:
java.lang.IllegalArgumentException

rlsdla

public void rlsdla(double[] data,
                   int noi)
RLS-DLA, prosess several training vectors by RLS-DLA. After 'noi' loops through the training set the dictionary is normalized, The weights are rescaled if logg is active. The variant with logging.

Parameters:
data - A concatenation of L vectors x each of length N, total length N*L
noi - Number of iterations to do through the data set.
Throws:
java.lang.IllegalArgumentException

rlsdla1

public void rlsdla1(double[] x)
RLS-DLA-1 Prosess a single training vector, one iteration of RLS-DLA. Include what is needed for logging, but also as fast as possible Normalize D only when D has drifted a given distance away from normalized. Updates class variables noTV, D, C (and DD if not null) also update vectors: w, r, u, v and scalars (doubles): sumxx, sumww, sumrr No control of arguments is done here.

Parameters:
x - A vector of length N

ilsdla

public void ilsdla(double[] data,
                   int noi)
ILS-DLA, prosess several training vectors by Iterative Least Squares, ILS-DLA. This function is not very effective, logging is turned on and always done

Parameters:
data - A concatenation of L vectors x each of length N, total length N*L
noi - Number of iterations to do through the data set.
Throws:
java.lang.IllegalArgumentException