Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 29305 invoked from network); 17 Aug 2009 17:58:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Aug 2009 17:58:42 -0000 Received: (qmail 35692 invoked by uid 500); 17 Aug 2009 17:58:47 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 35587 invoked by uid 500); 17 Aug 2009 17:58:47 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 35577 invoked by uid 99); 17 Aug 2009 17:58:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Aug 2009 17:58:46 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ted.dunning@gmail.com designates 209.85.211.185 as permitted sender) Received: from [209.85.211.185] (HELO mail-yw0-f185.google.com) (209.85.211.185) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Aug 2009 17:58:38 +0000 Received: by ywh15 with SMTP id 15so4296786ywh.10 for ; Mon, 17 Aug 2009 10:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=o+mhK8N9zQwsY3U6KoEXbR0drnm1QlbsGqNwAHarvyU=; b=VrqJPWgKG0Sle9NnQX17J1ZlGAoGIkVAz2XBL/0PcBdCHw4nzoUxg2dA2Hwfo8Iq+H CBG4CgmQDWm/nN4wQKDsTcDaWl5iMLJ0M7JqhwuOE5L9tSBuXQ2kF86a1WQ6HFz7FVrR XTPYxO3q1fJizNKCqhUtVUGUqDsxlW7fUuzpc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=u1mP6aOAszhPhwKWyAQ0ZsWM6l/x1yO/TC0jW+/4g3cN2IIG33E4h6r79dYnjuXOEi Mqs5hK6GvNISsjflk7Ui2Qg0KeaTcpiZHLDasDE03Nf05wpgsCKnCXmtdgnS5pnzhMwe 2wjC8tsy94cS/5pSfnmVt9XOWDDBM6+oop6UU= MIME-Version: 1.0 Received: by 10.151.25.13 with SMTP id c13mr6008975ybj.44.1250531898082; Mon, 17 Aug 2009 10:58:18 -0700 (PDT) In-Reply-To: <1922261993.829481250513609872.JavaMail.root@spooler6-g27.priv.proxad.net> References: <1118961004.829281250513602282.JavaMail.root@spooler6-g27.priv.proxad.net> <1922261993.829481250513609872.JavaMail.root@spooler6-g27.priv.proxad.net> From: Ted Dunning Date: Mon, 17 Aug 2009 10:57:58 -0700 Message-ID: Subject: Re: [math] Re: 2D Gaussian Fit To: Commons Users List Content-Type: multipart/alternative; boundary=000e0cd2989c90c4ca04715a2508 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd2989c90c4ca04715a2508 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 i= s a vector containing a position, then the multi-variate Gaussian is typicall= y written as N(x | m, S) =3D Z exp( - (x-m)' R (x-m) ) R is the inverse of the covariance matrix \Sigma and the normalizing constant Z =3D 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 prio= r expectation, but you can still get decent estimates. On Mon, Aug 17, 2009 at 5:53 AM, wrote: > Hi Jean-Fran=C3=A7ois, > > First, please use a [math] marker in the subject line when asking somethi= ng > about > commons-math. This mailing list is shared by all commons components so > these markers > help filtering messages. > > ----- "Jean-Francois Daune" a =C3=A9c= rit : > > > 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 mo= st > 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 librar= y. > In the > LevenbergMarquardtOptimizerTest class there is a Circle internal class th= at > implements a fitting > problems for observed points that should lie on a circle. You can use thi= s > as an example to > implement your own Gauss2D class. > > If this information is not sufficient, do not hesitate to ask and I'll tr= y > to provide more. > > Luc > > > > > > Any help is appreciated. > > > > J-F > > > > The contents of this e-mail 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 e-mail if you have received this e-mail by mistake and > > delete > > this e-mail from your system. E-mail transmission cannot be guaranteed > > to be > > secure or error-free. Ion Beam Applications does not accept liability > > for any > > such errors. Thank you for your cooperation. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > > For additional commands, e-mail: user-help@commons.apache.org > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > --=20 Ted Dunning, CTO DeepDyve --000e0cd2989c90c4ca04715a2508--