~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/statistics/mvcorrel.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [r]=mvcorrel(x)
 
2
//
 
3
//This function  computes r, the matrix  of correlation of
 
4
//the "tableau" x (x is  a numerical matrix mxn) who gives
 
5
//the values  of n variables for m  individuals: the (i,j)
 
6
//coefficient              of             r             is
 
7
//v(i,j)=E(xi-xibar)(xj-xjbar)/(stdi*stdj), where E is the
 
8
//first  moment of a  variable, xi  is the  i-th variable,
 
9
//xibar the mean of the  xi variable and stdi the standard
 
10
//deviation of the i-th variable.
 
11
//
 
12
//References: Saporta, Gilbert, Probabilites,  Analyse des
 
13
//Donnees et Statistique, Editions Technip, Paris, 1990.
 
14
//
 
15
//author: carlos klimann
 
16
//
 
17
//date: 2001-09-27
 
18
//
 
19
  if x==[] then s=%nan; return, end
 
20
  [lhs,rhs]=argn(0)
 
21
  if rhs <> 1 then error('mvcorrel requires only one argument.'), end
 
22
  [lx cx]=size(x)
 
23
  if lx==1 then r=zeros(lx,cx), return, end
 
24
  xbar=sum(x,'r')/lx
 
25
  r=x-ones(lx,1)*xbar
 
26
  std=(sum(r .^2,'r')) .^ .5
 
27
  r=(r'*r) ./ (std'*std)
 
28
endfunction