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 C950A10CD4 for ; Sat, 9 Nov 2013 09:42:45 +0000 (UTC) Received: (qmail 39517 invoked by uid 500); 9 Nov 2013 09:39:59 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 39428 invoked by uid 500); 9 Nov 2013 09:39:50 -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 39278 invoked by uid 99); 9 Nov 2013 09:39:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Nov 2013 09:39:03 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of andrea.antonello@gmail.com designates 74.125.82.177 as permitted sender) Received: from [74.125.82.177] (HELO mail-we0-f177.google.com) (74.125.82.177) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Nov 2013 09:38:56 +0000 Received: by mail-we0-f177.google.com with SMTP id x55so2873715wes.22 for ; Sat, 09 Nov 2013 01:38:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=mlQwDYzCQqq1/ci1A7Utw8dkVuvO1lK6IiO+yyL5ErE=; b=JpT/8guz36WCXbwPdE+6M+wLd6/MfUkwewjF/ZWozVEeXXCv09NydPeoPknOE0KfjU 8gylkKIBLeC4j2S1phFOGuYAmhVa8cVRtAK9evQeCZ5LMwOn9d8pZ08/HhdlY3GA0Gd2 sLD52SokUV7FUT1TD/T5vI3ecDQq0mRp5WvoKR8MYK+R4TyabVYfo3eDlR9wm7hU59/g Y3fkX9WJ2tTWjD8K9yQ/hsURIaGheMrwTsgLXwI5Cbgaw0FTp7tXVB5BYP2cgPZdBRmS B1FMOQeky8F4MnMaFzvJQ76Fqw9Ei0hJkgx4FRJRnl0oUAPFT6qAvIX6gzudp2nKllqL pO8Q== X-Received: by 10.180.97.5 with SMTP id dw5mr5417827wib.42.1383989916526; Sat, 09 Nov 2013 01:38:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.217.0.142 with HTTP; Sat, 9 Nov 2013 01:38:16 -0800 (PST) From: andrea antonello Date: Sat, 9 Nov 2013 10:38:16 +0100 Message-ID: Subject: [math] eigenvector doubts and issues To: user@commons.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Dear all, I have a doubt about using the eigenvector part of the library. I created a small dataset to represent 3d coordinates in a cartesian plane: double[] x = {1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3}; double[] y = {0.5, 1, 1.5, 2, 0.5, 1, 1.5, 2, 0.5, 1, 1.5, 2}; double[] z = {1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 2}; The datasset represents a step from z value 1 to 2 on a regular grid (with a diagonali trend). I would expect to gain from the eigenvector with lowest eigenvalue a line splitting this particular set in a quite clean way the higher z points from the lower ones. So I calculate the covariance matrix which results in: 0.7272727272727273 0.0 0.18181818181818182 0.0 0.3409090909090909 0.22727272727272727 0.18181818181818182 0.22727272727272727 0.2727272727272727 and then I simply calculate the eigenvector/values which result in: eigenVal: 0.8056498828134406, eigenVect: [0.9015723557614027, 0.19005937823202243, 0.38864472217295326] eigenVal: 0.4874287594020183, eigenVect: [-0.37995167578226796, 0.7774478202831089, 0.5012101463530935] eigenVal: 0.04783044869363171, eigenVect: [-0.20689130333844696, -0.5995434258526233, 0.773138842071603] doing exactly the same thing with Jama results in: eigenVal: 0.8056498828134406, eigenVect: [-0.7731388420716028, 0.5012101463530931, -0.38864472217295326] eigenVal: 0.48742875940201863, eigenVect: [0.5995434258526229, 0.7774478202831089, -0.1900593782320223] eigenVal: 0.0478304486936319, eigenVect: [0.20689130333844694, -0.37995167578226785, -0.9015723557614027] In fact if I use Jama's eigenvector with lowest eigenvalue, I am able to construct a line of slope y = (0.206891303338447/-0.379951675782268) *x, which splits my dataset the way I would like to have it. The same doesn't apply to the result of the apache commons math lib, which seems to be reflected on the secondary diagonal. Since I am no expert in this field, I might be doing somthing really wrong. If someone could give me a hint, it would be greatly appreciated. Best regards, Andrea --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org