Depending on what you mean by a 2D Gaussian fit, you may just need to
compute mean and covariance matrix to get what you need.
Remember that a 2D Gaussian needs center{x,y} and FOUR parameters for
variance, three of which are independent. The reason is that you can have a
Gaussian that is long and thin, but oriented at an arbitrary angle. If x is
a vector containing a position, then the multivariate Gaussian is typically
written as
N(x  m, S) = Z exp(  (xm)' R (xm) )
R is the inverse of the covariance matrix \Sigma and the normalizing
constant Z = 1 / \sqrt((2 pi)^n  \Sigma ).
With enough data, you can get fine estimates of these quantities directly,
without any optimization. With less data, you need to have a bit of a prior
expectation, but you can still get decent estimates.
On Mon, Aug 17, 2009 at 5:53 AM, <luc.maisonobe@free.fr> wrote:
> Hi JeanFrançois,
>
> First, please use a [math] marker in the subject line when asking something
> about
> commonsmath. This mailing list is shared by all commons components so
> these markers
> help filtering messages.
>
>  "JeanFrancois Daune" <JeanFrancois.Daune@ibagroup.com> a écrit :
>
> > Is it possible to perform a 2D Gaussian fit (giving center_x,
> > center_y, sigma_x, sigma_y, theta) with Commons Math?
>
> Yes it is possible. You will have to use the optimization package, and most
> probably
> the LevenbergMarquardtOptimizer class from the general subpackage. This
> will be the main
> algorithm that will perform the fit. You should implement your problem as
> your own class
> implementing the DifferentiableMultivariateVectorialFunction interface
> (i.e. a class
> that provides a "double[] value(double[] point)" method and a
> "MultivariateMatrixFunction
> jacobian()" method (which itself wraps another value function). In your
> case, the point[]
> parameters for both value functions will be the parameters of your fit,
> i.e. center_x, center_y,
> sigma_x, sigma_y and theta. You can look in the junit tests of the library.
> In the
> LevenbergMarquardtOptimizerTest class there is a Circle internal class that
> implements a fitting
> problems for observed points that should lie on a circle. You can use this
> as an example to
> implement your own Gauss2D class.
>
> If this information is not sufficient, do not hesitate to ask and I'll try
> to provide more.
>
> Luc
>
>
> >
> > Any help is appreciated.
> >
> > JF
> >
> > The contents of this email message and any attachments are intended
> > solely for
> > the recipient (s) named above. This communication is intended to be
> > and to
> > remain confidential and may be protected by intellectual property
> > rights. Any
> > use of the information contained herein (including but not limited to,
> > total or
> > partial reproduction, communication or distribution of any form) by
> > persons
> > other than the designated recipient(s) is prohibited. Please notify
> > the sender
> > immediately by email if you have received this email by mistake and
> > delete
> > this email from your system. Email transmission cannot be guaranteed
> > to be
> > secure or errorfree. Ion Beam Applications does not accept liability
> > for any
> > such errors. Thank you for your cooperation.
> >
> > 
> > To unsubscribe, email: userunsubscribe@commons.apache.org
> > For additional commands, email: userhelp@commons.apache.org
>
> 
> To unsubscribe, email: userunsubscribe@commons.apache.org
> For additional commands, email: userhelp@commons.apache.org
>
>

Ted Dunning, CTO
DeepDyve
