Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 93D3A11C62 for ; Thu, 14 Aug 2014 13:57:14 +0000 (UTC) Received: (qmail 23024 invoked by uid 500); 14 Aug 2014 13:57:13 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 22910 invoked by uid 500); 14 Aug 2014 13:57:13 -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 22892 invoked by uid 99); 14 Aug 2014 13:57:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Aug 2014 13:57:12 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of southlight25@gmail.com designates 209.85.213.180 as permitted sender) Received: from [209.85.213.180] (HELO mail-ig0-f180.google.com) (209.85.213.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Aug 2014 13:57:07 +0000 Received: by mail-ig0-f180.google.com with SMTP id l13so5041754iga.13 for ; Thu, 14 Aug 2014 06:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=VV6NyxgUJGn93+8D//Mk3tYuzrB/WkTjODqNPac5LJ8=; b=mFkKhus4aaW2hDd6XBHyb2fhHfViGw9ggW7klnlYIn4YOVz8v6l7rCJyPzBP81NmFo JRQmSm9p37haWfHkFEhddRD6pyBLLX6jYuBRpGlZp5+ZGtm8rKycowQhwuBY8/U+0NiF Ck97wV3mULHGIXXeIYYWPh/XzB+OWVG5ZMdZotHzrXGBsMD5DDzuKzP+Q5jFuEW67U8Y 2v8qpYwAkFENsqdXV15+jXf16sMbGuGFa4ekrkFT5YrndNICGIuaWbj1feXw7ggEjdg7 exwe2wmzvaZ750jHTJghTRPpNibLNtxMyJd+hF9Yc47wyRH0sNnsRf1cciaY/6g0qXC5 tpHw== X-Received: by 10.42.206.139 with SMTP id fu11mr5748655icb.47.1408024606951; Thu, 14 Aug 2014 06:56:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.250.133 with HTTP; Thu, 14 Aug 2014 06:56:26 -0700 (PDT) In-Reply-To: References: From: South Light Date: Thu, 14 Aug 2014 10:56:26 -0300 Message-ID: Subject: Re: [math] Curve fitting ... To: Commons Users List Content-Type: multipart/alternative; boundary=20cf303bff06884e180500974639 X-Virus-Checked: Checked by ClamAV on apache.org --20cf303bff06884e180500974639 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Ted, Thanks a lot for your suggestion but I need to add it using java. Thanks =E2=80=8Bagain=E2=80=8B .=E2=80=8B 2014-08-14 2:22 GMT-03:00 Ted Dunning : > Have you considered using an interactive system like R, Matlab or Octave? > > You might be happier. > > Or even have you considered goal search in Excel? > > > > > On Wed, Aug 13, 2014 at 6:08 PM, South Light > wrote: > > > Hi, > > > > May be someone can help me with this problem. > > > > Given the follow function: y =3D 10 ^ ((x + 82) / (-10 * A)) > > > > I would like to found the A value witch curve fit better for a set of x= ,y > > values, usually the set is about 20 to 25 x,y values. > > > > I use the CurveFitter class and the ParametricUnivariateFunction > > > > > > ParametricUnivariateFunction function =3D new > ParametricUnivariateFunction() > > { > > > > =E2=80=8B =E2=80=8B > > @Override > > =E2=80=8B =E2=80=8B > > public double[] gradient(double x, double[] params) { > > =E2=80=8B > > (????? comment) > > =E2=80=8B =E2=80=8B > > } > > > > =E2=80=8B =E2=80=8B > > @Override > > =E2=80=8B =E2=80=8B > > public double value(double x, double[] params) { > > > > =E2=80=8B =E2=80=8B > > double a =3D params[0]; > > > > =E2=80=8B =E2=80=8B > > return Math.pow(10, ((x + 82) / > > =E2=80=8B(=E2=80=8B > > -10 * > > =E2=80=8Ba > > =E2=80=8B)=E2=80=8B > > )); > > > > =E2=80=8B =E2=80=8B > > } > > > > }; > > > > LevenbergMarquardtOptimizer optimizer =3D new > LevenbergMarquardtOptimizer(); > > > > CurveFitter fitter =3D new > > CurveFitter(optimizer); > > > > double[] x =3D { > > -82 > > , > > =E2=80=8B-85 > > , > > =E2=80=8B-89 > > }; > > > > double[] y =3D { > > =E2=80=8B1 > > , > > =E2=80=8B1.4 > > , > > =E2=80=8B2 > > }; > > > > for (int i =3D 0; i < x.length; i++) > > =E2=80=8B =E2=80=8B > > fitter.addObservedPoint(x[i], y[i]); > > > > double[] result =3D fitter.fit(function, new double[] { 1, 10 }); > > > > > > > > =E2=80=8BA. =E2=80=8BIs this the best way to solve the problem or there= 's another better > > way? > > > > B. What do we need to write on the gradient area (????? comment) ?=E2= =80=8B > > > > Any help will be more then welcome. > > > > Many thanks !! > > > --20cf303bff06884e180500974639--