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 D7FAD11E51 for ; Thu, 14 Aug 2014 05:23:21 +0000 (UTC) Received: (qmail 32887 invoked by uid 500); 14 Aug 2014 05:23:21 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 32776 invoked by uid 500); 14 Aug 2014 05:23:21 -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 32761 invoked by uid 99); 14 Aug 2014 05:23:20 -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 05:23:20 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ted.dunning@gmail.com designates 209.85.213.175 as permitted sender) Received: from [209.85.213.175] (HELO mail-ig0-f175.google.com) (209.85.213.175) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Aug 2014 05:23:15 +0000 Received: by mail-ig0-f175.google.com with SMTP id uq10so12508088igb.8 for ; Wed, 13 Aug 2014 22:22:54 -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=YGVnMFGKLBSQ8RQvfnQ4ga512vfP1rSamp4TXaXR55I=; b=pn/Urci6GyblyF6KtO5UmGL4mt2AYqR5ZgEVluLgPC5iblE+0aDxqyDlYX25qb6QpR 7Ah2EjquI7E6Qn1pMjIgvvgomcmj+LpPJJCOUmx0rb488dsET+yaumTUqzP6nEGPteK+ 5YlZ7fPzBqcXkhtWobYTSBLLVAP68acL512wx3Vp/lALUF5tNDyJm+J+sjbHHdDSvNjR 6qn6XXLe4scQw6RS21pj2to9mK5JLkcCNTLOrTCWsc5s4i4amfddLeyv2tiy+Y8+yHWP 1fEYFMG6cQInceulQrvTYe36sY1qbCELiIw+fA0Ld4NZG0nxujOX32eHVQEo5tYzrXnJ 2mQw== X-Received: by 10.43.164.130 with SMTP id ms2mr11869045icc.9.1407993774527; Wed, 13 Aug 2014 22:22:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.225.167 with HTTP; Wed, 13 Aug 2014 22:22:24 -0700 (PDT) In-Reply-To: References: From: Ted Dunning Date: Wed, 13 Aug 2014 22:22:24 -0700 Message-ID: Subject: Re: [math] Curve fitting ... To: Commons Users List Content-Type: multipart/alternative; boundary=001a11c30ad0c6f8050500901842 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c30ad0c6f8050500901842 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 ParametricUnivariateFuncti= on() > { > > =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 !! > --001a11c30ad0c6f8050500901842--