Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

riso.distributions
Class Mises  view Mises download Mises.java

java.lang.Object
  extended byriso.distributions.AbstractDistribution
      extended byriso.distributions.Mises
All Implemented Interfaces:
ConditionalDistribution, Distribution, java.io.Serializable

public class Mises
extends AbstractDistribution

An instance of this class represent a von Mises distribution, also called a circular Gaussian distribution.


Field Summary
 double a
          The location parameter of this distribution.
 double b
          The scale parameter of this distribution.
 
Fields inherited from class riso.distributions.AbstractDistribution
associated_variable
 
Constructor Summary
Mises()
          Construct an instance with default parameters, namely a==0 and b==1.
Mises(double a, double b)
          Constructs a lognormal with the specified parameters.
 
Method Summary
 double[] effective_support(double epsilon)
          Returns an interval which contains almost all of the mass of this distribution.
 double expected_value()
          Returns the expected value of this distribution.
 java.lang.String format_string(java.lang.String leading_ws)
          Formats a string representation of this distribution.
static double I10_ratio(double u)
          Computes the ratio I1(u)/I0(u) for the argument u.
 double log_prior()
          Computes the log of the prior probability of the parameters of this distribution, assuming some prior distribution has been established.
 int ndimensions()
          Returns the number of dimensions in which this distribution lives.
 double p(double[] x)
          Compute the density at the point x.
 void pretty_input(riso.general.SmarterTokenizer st)
          Read an instance of this distribution from an input stream.
 double[] random()
          Returns an instance of a random variable from this distribution.
 double sqrt_variance()
          Returns the square root of the variance of this distribution.
 double update(double[][] theta, double[] responsibility, int niter_max, double stopping_criterion)
          Uses data to modify the parameters of the distribution.
 double weighted_nll(double[][] theta, double[] responsibility)
          Computes the negative log likelihood, weighting each case by the responsibility.
 
Methods inherited from class riso.distributions.AbstractDistribution
cdf, clone, get_density, get_nstates, initial_mix, log_p, ndimensions_child, ndimensions_parent, p, parse_string, pretty_output, random, set_variable, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

a

public double a
The location parameter of this distribution. Don't modify this parameter -- create a new instance if a different parameter is needed.


b

public double b
The scale parameter of this distribution. Don't modify this parameter -- create a new instance if a different parameter is needed.

Constructor Detail

Mises

public Mises()
Construct an instance with default parameters, namely a==0 and b==1.


Mises

public Mises(double a,
             double b)
Constructs a lognormal with the specified parameters.

Method Detail

ndimensions

public int ndimensions()
Returns the number of dimensions in which this distribution lives. This number is always 1.

Specified by:
ndimensions in interface Distribution
Overrides:
ndimensions in class AbstractDistribution

p

public double p(double[] x)
Compute the density at the point x. Density function given by Weisstein, ``Von Mises Distribution.''


log_prior

public double log_prior()
                 throws java.lang.Exception
Computes the log of the prior probability of the parameters of this distribution, assuming some prior distribution has been established. This may not be meaningful.

Specified by:
log_prior in interface Distribution
Overrides:
log_prior in class AbstractDistribution

random

public double[] random()
                throws java.lang.Exception
Returns an instance of a random variable from this distribution.

Specified by:
random in interface Distribution
Overrides:
random in class AbstractDistribution

update

public double update(double[][] theta,
                     double[] responsibility,
                     int niter_max,
                     double stopping_criterion)
              throws java.lang.Exception
Uses data to modify the parameters of the distribution. This method implements the maximum likelihood formulas worked out in hand-written notes, 8 Dec 2001. Let theta[i] be a list of angles. Let S = \sum_i sin theta[i]. Let C = \sum_i cos theta[i]. Let R^2 = S^2 + C^2. Then the maximum likelihood estimate of the parameter a is atan2(S,C), and the m.l. estimate of b is a solution of (sin \hat a)/S R^2/n = I1(b)/I0(b), where n is the number of data and I0, I1 are the modified Bessel functions of the first kind and orders zero and one, respectively.

Specified by:
update in interface Distribution
Overrides:
update in class AbstractDistribution

I10_ratio

public static double I10_ratio(double u)
Computes the ratio I1(u)/I0(u) for the argument u.


weighted_nll

public double weighted_nll(double[][] theta,
                           double[] responsibility)
Computes the negative log likelihood, weighting each case by the responsibility.


expected_value

public double expected_value()
Returns the expected value of this distribution.

Specified by:
expected_value in interface Distribution
Overrides:
expected_value in class AbstractDistribution

sqrt_variance

public double sqrt_variance()
                     throws java.lang.Exception
Returns the square root of the variance of this distribution.

Specified by:
sqrt_variance in interface Distribution
Overrides:
sqrt_variance in class AbstractDistribution

effective_support

public double[] effective_support(double epsilon)
                           throws java.lang.Exception
Returns an interval which contains almost all of the mass of this distribution. ALWAYS RETURNS [0,2 PI] !!! WE CAN DO BETTER !!!

Specified by:
effective_support in interface Distribution
Overrides:
effective_support in class AbstractDistribution

format_string

public java.lang.String format_string(java.lang.String leading_ws)
Formats a string representation of this distribution. Since the representation is only one line of output, the argument leading_ws is ignored.

Specified by:
format_string in interface ConditionalDistribution
Overrides:
format_string in class AbstractDistribution

pretty_input

public void pretty_input(riso.general.SmarterTokenizer st)
                  throws java.io.IOException
Read an instance of this distribution from an input stream. This is intended for input from a human-readable source; this is different from object serialization.

Overrides:
pretty_input in class AbstractDistribution