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 D2596DD59 for ; Thu, 26 Jul 2012 17:13:09 +0000 (UTC) Received: (qmail 96287 invoked by uid 500); 26 Jul 2012 17:13:08 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 96177 invoked by uid 500); 26 Jul 2012 17:13:08 -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 96168 invoked by uid 99); 26 Jul 2012 17:13:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jul 2012 17:13:08 +0000 X-ASF-Spam-Status: No, hits=-2.8 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,RCVD_IN_DNSWL_HI,SPF_PASS,TVD_FW_GRAPHIC_NAME_MID X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gkane@us.ibm.com designates 32.97.182.139 as permitted sender) Received: from [32.97.182.139] (HELO e9.ny.us.ibm.com) (32.97.182.139) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jul 2012 17:12:59 +0000 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 26 Jul 2012 13:12:08 -0400 Received: from d01dlp03.pok.ibm.com (9.56.224.17) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 26 Jul 2012 13:12:06 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 58BF6C9002C for ; Thu, 26 Jul 2012 13:12:05 -0400 (EDT) Received: from d01av05.pok.ibm.com (d01av05.pok.ibm.com [9.56.224.195]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6QHC5Jb385312 for ; Thu, 26 Jul 2012 13:12:05 -0400 Received: from d01av05.pok.ibm.com (loopback [127.0.0.1]) by d01av05.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6QHC4f3021270 for ; Thu, 26 Jul 2012 13:12:04 -0400 Received: from d01ml259.pok.ibm.com (d01ml259.pok.ibm.com [9.63.8.58]) by d01av05.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6QHC4CE021267 for ; Thu, 26 Jul 2012 13:12:04 -0400 In-Reply-To: <20120726155029.GZ20488@dusk.harfang.homelinux.org> References: <20120726155029.GZ20488@dusk.harfang.homelinux.org> Subject: Re: [MATH] Kalman Filter X-KeepSent: 667C2897:C9AE4BCC-85257A47:005DEADC; type=4; name=$KeepSent To: "Commons Users List" X-Mailer: Lotus Notes Release 8.5.3 September 15, 2011 Message-ID: From: Garrett Kane Date: Thu, 26 Jul 2012 13:12:00 -0400 X-MIMETrack: Serialize by Router on D01ML259/01/M/IBM(Release 8.5.3 ZX853HP5|January 12, 2012) at 07/26/2012 13:12:04 MIME-Version: 1.0 Content-type: multipart/related; Boundary="0__=0ABBF0D4DFCE6C4C8f9e8a93df938690918c0ABBF0D4DFCE6C4C" X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12072617-7182-0000-0000-00000215126B --0__=0ABBF0D4DFCE6C4C8f9e8a93df938690918c0ABBF0D4DFCE6C4C Content-type: multipart/alternative; Boundary="1__=0ABBF0D4DFCE6C4C8f9e8a93df938690918c0ABBF0D4DFCE6C4C" --1__=0ABBF0D4DFCE6C4C8f9e8a93df938690918c0ABBF0D4DFCE6C4C Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: quoted-printable The code I am using (copied from the apache commons page on the kalman filter) is: public class Kalman { void main(){ System.out.println("BEGINNING"); double constantVoltage =3D 10d; double measurementNoise =3D 0.1d; double processNoise =3D 1e-5d; // A =3D [ 1 ] RealMatrix A =3D new Array2DRowRealMatrix(new double[] { 1d }); // B =3D null RealMatrix B =3D null; // H =3D [ 1 ] RealMatrix H =3D new Array2DRowRealMatrix(new double[] { 1d }); // x =3D [ 10 ] RealVector x =3D new ArrayRealVector(new double[] { constantVoltage }); // Q =3D [ 1e-5 ] RealMatrix Q =3D new Array2DRowRealMatrix(new double[] { processNoise }); // P =3D [ 1 ] RealMatrix P0 =3D new Array2DRowRealMatrix(new double[] { 1d }); // R =3D [ 0.1 ] RealMatrix R =3D new Array2DRowRealMatrix(new double[] { measurementNoise }); System.out.println("anywhere"); ProcessModel pm =3D new DefaultProcessModel(A, B, Q, x, P0); MeasurementModel mm =3D new DefaultMeasurementModel(H, R); KalmanFilter filter =3D new KalmanFilter(pm, mm); System.out.println("there"); // process and measurement noise vectors RealVector pNoise =3D new ArrayRealVector(1); RealVector mNoise =3D new ArrayRealVector(1); System.out.println("here"); RandomGenerator rand =3D new JDKRandomGenerator(); // iterate 60 steps for (int i =3D 0; i < 60; i++) { System.out.println("beginning"); filter.predict(); System.out.println("after Predict"); // simulate the process pNoise.setEntry(0, processNoise * rand.nextGaussian()); System.out.println("after setEntry"); // x =3D A * x + p_noise x =3D A.operate(x).add(pNoise); System.out.println("after adding pNoise"); // simulate the measurement mNoise.setEntry(0, measurementNoise * rand.nextGaussian ()); System.out.println("after 2nd setEntry"); // z =3D H * x + m_noise RealVector z =3D H.operate(x).add(mNoise); System.out.println("after adding mNoise"); filter.correct(z); System.out.println("after correct"); double voltage =3D filter.getStateEstimation()[0]; System.out.println("at the end"); } } } Here is a (very small) sample of the output. full output is over 1100 lines. EXP_INT_TABLE_A=3D { +0.0d, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, +1.2167807682331913E-308d, +3.3075532478807267E-308d, +8.990862214387203E-308d, }; EXP_INT_TABLE_B=3D { +0.0d, Double.NaN, Double.NaN, Double.NaN, }; LN_MANT { {+0.0d, +0.0d, }, // 0 {+9.760860120877624E-4d, -3.903230345984362E-11d, }, // 1 {+0.0019512202125042677d, -8.124251825289188E-11d, }, // 2 {+0.0029254043474793434d, -1.8374207360194882E-11d,}, // 3 {+0.0038986406289041042d, -2.1324678121885073E-10d,}, // 4 {+0.004870930686593056d, -4.5199654318611534E-10d,}, // 5 {+0.00584227591753006d, -2.933016992001806E-10d, }, // 6 {+0.006812678650021553d, -2.325147219074669E-10d, }, // 7 {+0.007782140746712685d, -3.046577356838847E-10d, }, // 8 {+0.008750664070248604d, -5.500631513861575E-10d, }, // 9 {+0.6916812658309937d, -2.9535446262017846E-9d, }, // 1021 {+0.6921701431274414d, -2.2153227096187463E-9d, }, // 1022 {+0.6926587820053101d, -1.943473623641502E-9d, }, // 1023 }; SINE_TABLE_A=3D { +0.0d, +0.1246747374534607d, +0.24740394949913025d, +0.366272509098053d, The output contains A and B tables for sine, cosine, and tangent. The A= tables seem to be on the numerical scale of SINE_TABLE_A, and the B tab= les are on the scale of E-8 or so. From: Gilles Sadowski To: user@commons.apache.org, Date: 07/26/2012 11:54 Subject: Re: [MATH] Kalman Filter On Thu, Jul 26, 2012 at 11:21:09AM -0400, Garrett Kane wrote: > > > I am having trouble understanding the output of the Kalman Filter in = math > 3.0 is there anyone who can explain to me what the various trigonomet= ric, > exp, and lp_mant tables in the console output are used for? my eventu= al > goal is to feed output from this filter into a graphing engine to com= pare > real/predicted data but obviously I need to understand the output fir= st. > Thanks > -Garrett http://markmail.org/message/a2r45shfg7w2iw7f Regards, Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org = --1__=0ABBF0D4DFCE6C4C8f9e8a93df938690918c0ABBF0D4DFCE6C4C Content-type: text/html; charset=US-ASCII Content-Disposition: inline Content-transfer-encoding: quoted-printable

The code I am using (copied fro= m the apache commons page on the kalman filter) is:
public class Kalman {
void main(){
System.out.println("BEGINNING");
double constantVoltage =3D 10d;
double measurementNoise =3D 0.1d;
double processNoise =3D 1e-5d;

// A =3D [ 1 ]
RealMatrix A =3D new Array2DRowRealMatrix(new double[]= { 1d });
// B =3D null
RealMatrix B =3D null;
// H =3D [ 1 ]
RealMatrix H =3D new Array2DRowRealMatrix(new double[]= { 1d });
// x =3D [ 10 ]
RealVector x =3D new ArrayRealVector(new double[] { co= nstantVoltage });
// Q =3D [ 1e-5 ]
RealMatrix Q =3D new Array2DRowRealMatrix(new double[]= { processNoise });
// P =3D [ 1 ]
RealMatrix P0 =3D new Array2DRowRealMatrix(new double= [] { 1d });
// R =3D [ 0.1 ]
RealMatrix R =3D new Array2DRowRealMatrix(new double[]= { measurementNoise });
System.out.println("anywhere");
ProcessModel pm =3D new DefaultProcessModel(A, B, Q, x, P0);
MeasurementModel mm =3D new
 DefaultMeasurementModel(H, R);
KalmanFilter filter =3D new
 KalmanFilter(pm, mm);  
System.out.println("there")= ;
// process and measurement noise vectors

RealVector pNoise =3D new
 ArrayRealVector(1);
RealVector mNoise =3D new ArrayRealVector(1);
System.out.println("here");=
RandomGenerator rand =3D new JDKRandomGenerator();
// iterate 60 steps
for (int i =3D 0; i= < 60; i++) {
System.out.println("beginning");
filter.predict();

System.out.println("after Predict");
// simulate the process
pNoise.setEntry(0, processNoise *= rand.nextGaussian());

System.out.println("after setEntry");
// x =3D A * x + p_noise
x =3D A.operate(x).add(pNoise);

System.out.println("after adding pNoise");
// simulate the measurement
mNoise.setEntry(0, measurementNoi= se * rand.nextGaussian());

System.out.println("after 2nd setEntry");
// z =3D H * x + m_noise
RealVector z =3D H.operate(x).add= (mNoise);

System.out.println("after adding mNoise");
filter.correct(z);

System.out.println("after correct");
double voltage =3D filter.getStateEs= timation()[0];
System.out.println("at the end");
}
}
}

Here is a (very small) sample of t= he output.  full output is over 1100 lines.
EXP_INT_TABLE_A=3D
    {
        +0.0d,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
        +1.21678= 07682331913E-308d,
        +3.30755= 32478807267E-308d,
        +8.99086= 2214387203E-308d,
    };
EXP_INT_TABLE_B=3D
    {
        +0.0d,
        Double.N= aN,
        Double.N= aN,
        Double.N= aN,
    };
LN_MANT
    {
        {+0.0d, =                   +0.0d, &= nbsp;                 }, // 0
        {+9.7608= 60120877624E-4d,  -3.903230345984362E-11d, }, // 1
        {+0.0019= 512202125042677d, -8.124251825289188E-11d, }, // 2
        {+0.0029= 254043474793434d, -1.8374207360194882E-11d,}, // 3
        {+0.0038= 986406289041042d, -2.1324678121885073E-10d,}, // 4
        {+0.0048= 70930686593056d,  -4.5199654318611534E-10d,}, // 5
        {+0.0058= 4227591753006d,   -2.933016992001806E-10d, }, // 6
        {+0.0068= 12678650021553d,  -2.325147219074669E-10d, }, // 7
        {+0.0077= 82140746712685d,  -3.046577356838847E-10d, }, // 8
        {+0.0087= 50664070248604d,  -5.500631513861575E-10d, }, // 9
  {+0.6916812658309937d,  =  -2.9535446262017846E-9d, }, // 1021
        {+0.6921= 701431274414d,    -2.2153227096187463E-9d, }, // 1022<= br>         {+0.6926= 587820053101d,    -1.943473623641502E-9d,  }, // 1023

    };
SINE_TABLE_A=3D
    {
        +0.0d,
        +0.12467= 47374534607d,
        +0.24740= 394949913025d,
        +0.36627= 2509098053d,


The output contains A and B tables= for sine, cosine, and tangent. The A tables seem to be on the numerica= l scale of SINE_TABLE_A, and the B tables are on the scale of E-8 or so= .
3D"InactiveGilles Sadowski ---07/26/2012 11:54:03---On Thu, Jul 26, 201= 2 at 11:21:09AM -0400, Garrett Kane wrote: >

From: Gilles Sadowski <gilles@harfang.ho= melinux.org>

To: user@commons.apache.org,

Date: 07/26/2012 11:54
Subject: = Re: [MATH] Kalman Filter





On Thu, Jul 26, 2012 at 11:21:09AM -0400, Garrett = Kane wrote:
>
>
> I am having trouble understanding the output of the Kalman Filter = in math
> 3.0 is there anyone who can explain to me what the various trigono= metric,
> exp, and lp_mant tables in the console output are used for? my eve= ntual
> goal is to feed output from this filter into a graphing engine to = compare
> real/predicted data but obviously I need to understand the output = first.
> Thanks
> -Garrett

http://markmail.org/message/a2r45shfg7w2iw7f


Regards,
Gilles

--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


= --1__=0ABBF0D4DFCE6C4C8f9e8a93df938690918c0ABBF0D4DFCE6C4C-- --0__=0ABBF0D4DFCE6C4C8f9e8a93df938690918c0ABBF0D4DFCE6C4C--