Unmesha SreeVeni - 1 year ago 118
Java Question

# Principal Component Analysis in java

I am trying to achieve multiplication in array for doing PCA in java

I calculated mean and substrtacted it from each x values.Next I need to find covarience

So inorder to find that I need to multiply all the combinations in a given array

`````` [a,b,c] --> (aa)(ab)(ac)(bb)(bc)(cc)
``````

How to construct a matrix of all possible products?

Whether taking subset and multiplying solves the problem?

You are computing a matricial product. Say `A = [a, b, c]` (horizontal vector), you get an obviously symetric matrix by :

M = tA . A

The upper part of the matrix is composed of all possible products.

``````aa ab ac
ba bb bc
ca cb cc
``````

When computing, you can use the symetry :

``````for(int i=0; i<len; i++) {
for (int j=0; j<=i; j++) { // do not go up to len but stop at i ...
// computations ...
}
}
``````
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download