epfl.pdf
Class NormalKernelPdf

java.lang.Object
  |
  +--epfl.pdf.AbstractPdf
        |
        +--epfl.pdf.NormalKernelPdf
All Implemented Interfaces:
Pdf, VectorReader

public class NormalKernelPdf
extends AbstractPdf

A probability density function based on normal kernels


Inner Class Summary
static class NormalKernelPdf.NormalKernel
          A normal kernel class
 
Field Summary
 double missingValCode
          Missing value code
 double missingValSubst
          Missing value substitute
 
Constructor Summary
NormalKernelPdf(int nKernels, double minMu, double maxMu, double sigma, java.lang.String name, double missingValCode, double missingValSubst)
          Creates a new pdf without stream connection
NormalKernelPdf(TagReader config, java.lang.String name)
          Creates a new pdf without stream connection
NormalKernelPdf(TagReader config, java.lang.String name, VectorReader in)
          Creates a new pdf with normal kernels read in a tag reader
NormalKernelPdf(VectorReader in, int nKernels, double minMu, double maxMu, double sigma, java.lang.String name, double missingValCode, double missingValSubst)
          Creates a new pdf with normal kernels
 
Method Summary
 void addKernel(double weight, double mu, double sigma)
          Adds a new normal kernel
 boolean areKernelWeightsValid()
          Checks if the kernel weights are positive and sum to 1.0
 NormalKernelPdf.NormalKernel getKernel(int index)
          Returns the kernel at the given index
 int nKernels()
          Returns the number of kernels
 double pdf(double x_)
          Probability density function
 void tagWrite(TagWriter out)
          Writes a tag representation for this pdf in a tag writer
 void tagWrite(TagWriter out, TagWriter.Indent _indent)
          Writes a tag representation for this pdf in a tag writer
 java.lang.String toString()
          Returns a string representation for this pdf
 
Methods inherited from class epfl.pdf.AbstractPdf
close, period, plot, read, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

missingValCode

public double missingValCode
Missing value code

missingValSubst

public double missingValSubst
Missing value substitute
Constructor Detail

NormalKernelPdf

public NormalKernelPdf(VectorReader in,
                       int nKernels,
                       double minMu,
                       double maxMu,
                       double sigma,
                       java.lang.String name,
                       double missingValCode,
                       double missingValSubst)
Creates a new pdf with normal kernels
Parameters:
in - the underlying vector reader
nKernels - the initial number of kernels
The kernel mu parameter is set to a random value between minMu and maxMu; the sigma parameters are equal to sigma and the weight value is equal to 1.0/nKernels
name - the pdf name

NormalKernelPdf

public NormalKernelPdf(int nKernels,
                       double minMu,
                       double maxMu,
                       double sigma,
                       java.lang.String name,
                       double missingValCode,
                       double missingValSubst)
Creates a new pdf without stream connection

NormalKernelPdf

public NormalKernelPdf(TagReader config,
                       java.lang.String name,
                       VectorReader in)
                throws java.io.IOException
Creates a new pdf with normal kernels read in a tag reader
Parameters:
config - the tag reader to configure the kernels
tag - the tag name enclosing the kernels parameters
The file format must be :
<tag>
  <missingValCode> double </missingValCode>
  <missingValSubst>double </missingValSubst>
  <nKernels> int </nKernels>
  <kernels>
   {double (weight) double (mu) double (sigma) } nKernels
  </kernels>
</tag>
in - the underlying vector reader
Throws:
java.io.IOException - if there is an error in file format

NormalKernelPdf

public NormalKernelPdf(TagReader config,
                       java.lang.String name)
                throws java.io.IOException
Creates a new pdf without stream connection
Method Detail

pdf

public double pdf(double x_)
Probability density function
Overrides:
pdf in class AbstractPdf

getKernel

public NormalKernelPdf.NormalKernel getKernel(int index)
Returns the kernel at the given index

addKernel

public void addKernel(double weight,
                      double mu,
                      double sigma)
Adds a new normal kernel
Parameters:
weight - the kernel weight

nKernels

public int nKernels()
Returns the number of kernels

areKernelWeightsValid

public boolean areKernelWeightsValid()
Checks if the kernel weights are positive and sum to 1.0

toString

public java.lang.String toString()
Returns a string representation for this pdf
Overrides:
toString in class java.lang.Object

tagWrite

public void tagWrite(TagWriter out,
                     TagWriter.Indent _indent)
Writes a tag representation for this pdf in a tag writer

tagWrite

public void tagWrite(TagWriter out)
Writes a tag representation for this pdf in a tag writer