epfl.pdf
Class AbstractPdf

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

public abstract class AbstractPdf
extends java.lang.Object
implements Pdf

The root class for all probability density functions


Constructor Summary
AbstractPdf()
          Creates a new pdf without stream connection
AbstractPdf(VectorReader in)
          Creates a new pdf
 
Method Summary
 void close()
          Closes the stream
abstract  double pdf(double x)
          Probability density function
 int period()
          Returns the stream period
 void plot(double xMin, double xMax, int nPoints, VectorWriter out)
          Plots the pdf in a vector writer
 double[] read()
          Reads a vector in stream
 int size()
          Returns the stream size (vector size)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPdf

public AbstractPdf(VectorReader in)
Creates a new pdf
Parameters:
in - the underlying vector reader

AbstractPdf

public AbstractPdf()
Creates a new pdf without stream connection
Method Detail

pdf

public abstract double pdf(double x)
Probability density function
Specified by:
pdf in interface Pdf

plot

public void plot(double xMin,
                 double xMax,
                 int nPoints,
                 VectorWriter out)
          throws java.io.IOException
Plots the pdf in a vector writer
Specified by:
plot in interface Pdf
Parameters:
out - the vector writer size must be 2, out[0] = x and out[1] = pdf(x)
Throws:
java.io.IOException - if an IO error occurs

read

public double[] read()
              throws java.io.IOException
Reads a vector in stream
Specified by:
read in interface VectorReader
Throws:
java.io.IOException - if the stream is closed or if it is unable to read size doubles

size

public int size()
Returns the stream size (vector size)
Specified by:
size in interface VectorReader

period

public int period()
Returns the stream period
Specified by:
period in interface VectorReader
Returns:
0 if the stream is not periodic

close

public void close()
           throws java.io.IOException
Closes the stream
Specified by:
close in interface VectorReader
Throws:
java.io.IOException - if an IO error occurs