pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Covariance Matrix


From: John Darrington
Subject: Re: Covariance Matrix
Date: Thu, 8 Oct 2009 11:34:54 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

On Wed, Oct 07, 2009 at 07:35:10PM -0400, Jason Stover wrote:
     On Wed, Oct 07, 2009 at 03:17:55PM -0400, Jason Stover wrote:
     > But that isn't the total number of categories that must be considered
     > for the covariance matrix. For example, if our dictionary had the
     > variables v1, v2 and v3, and v1 had n1 categories, v2 had n2
     > categories and v3 had n3 categories, then our covariance matrix would
     > need to have (n1 - 1)*(n2 - 1)*(n3 - 1) rows. I guess we could compute
     > this value in category.c, but what if someone only wanted a covariance
     > matrix for just v1 and v2? Then the the number of rows necessary would be
     > (n1 - 1) * (n2 - 1). Or maybe they would want v2 and v3, then we would
     > need (n2 - 1)*(n3 - 1) rows.
     
     I made a mistake here: The dimensions would be (n1-1)+(n2-1)+(n3-1),
     or (n1-1)+(n2-1), etc., but not (n1-1)*(n2-1). Oops. 
     
My idea is to calculate the number of categories on each procedure (that needs 
it).
So instead of the categories data having global scope, they will be created on 
demand
(in this case inside the covariance matrix constructure).

So the constructor for the covariance matrix would be passed (in addition to its
current parameters) a set of categorical variables.  The total number of 
categories
can be calculated in the first pass.  Thus the code would become something like:

create_covariance (const struct variable **vars, int n_vars, 
  const struct variable **catvars, int n_cat_vars)
{
 ...
 cov->categories = create_categories (catvars, n_cat_vars);
}

void
covariance_first_pass (struct covariance *cov, const struct ccase *c)
{
 categories_update (cov->categories, c);
 ...
}

int
get_dim (const struct covariance *cov)
{
 return cov->n_vars + categories_total_number_of_categories (cov->categories); 
}


This involves rewriting some code, but I think it will be worthwhile.  We don't
need the total number of categories until AFTER the first pass of the procedure.

-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]