Maxima – 231 – descriptive – 8

sherit

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.726.

cdf_empirical (list, option ...)
cdf_empirical (matrix, option ...)
Empirical distribution function F(x).

Data can be introduced as a list of numbers, or as a one column matrix.

The optional argument is the name of the variable in the returned expression, which is x by default.

Empirical distribution function.

(%i1) load ("descriptive")$

(%i2) F(x):= ''(cdf_empirical([1,3,3,5,7,7,7,8,9]));
(%o2) F(x) := (charfun(x >= 9) + charfun(x >= 8) + 3 charfun(x >= 7)
                     + charfun(x >= 5) + 2 charfun(x >= 3) + charfun(x >= 1))/9
(%i3) F(6);
                                       4
(%o3)                                  -
                                       9
(%i4) load(draw)$

(%i5) draw2d(line_width = 3, grid = true, explicit(F(z), z, -2, 12)) $

231-0

cov (matrix)
The covariance matrix of the multivariate sample, defined as

231-1

where Xj is the j-th row of the sample matrix.

(%i6) s2 : read_matrix (file_search ("wind.data"))$

(%i7) fpprintprec : 7$ /* change precision for pretty output */
(%i8) cov (s2);
             [ 17.2219   13.61811  14.37216  19.39623  15.42162 ]
             [                                                  ]
             [ 13.61811  14.98773  13.30448  15.15833  14.97109 ]
             [                                                  ]
(%o8)        [ 14.37216  13.30448  15.47572  17.32543  16.1817  ]
             [                                                  ]
             [ 19.39623  15.15833  17.32543  32.17651  20.44684 ]
             [                                                  ]
             [ 15.42162  14.97109  16.1817   20.44684  24.42307 ]

cov1 (matrix)
The covariance matrix of the multivariate sample, defined as

231-2

where Xj is the j-th row of the sample matrix.

(%i9) s2 : read_matrix (file_search ("wind.data"))$

(%i10) fpprintprec : 7$ /* change precision for pretty output */
(%i11) cov1 (s2);
             [ 17.39586  13.75567  14.51734  19.59215  15.57739 ]
             [                                                  ]
             [ 13.75567  15.13912  13.43886  15.31145  15.12232 ]
             [                                                  ]
(%o11)       [ 14.51734  13.43886  15.63205  17.50044  16.34516 ]
             [                                                  ]
             [ 19.59215  15.31145  17.50044  32.50152  20.65338 ]
             [                                                  ]
             [ 15.57739  15.12232  16.34516  20.65338  24.66977 ]

global_variances (matrix)
global_variances (matrix, options ...)
Function global_variances returns a list of global variance measures:

where p is the dimension of the multivariate random variable and S1 the covariance matrix returned by cov1.

Option: 'data, default 'true, indicates whether the input matrix contains the sample data, in which case the covariance matrix cov1 must be calculated, or not, and then the covariance matrix (symmetric) must be given, instead of the data.

(%i1) load ("descriptive")$

(%i2) s2 : read_matrix (file_search ("wind.data"))$

(%i3) global_variances (s2);
(%o3) [105.3383420606059, 21.06766841212119, 12874.34690469686,
                       113.4651792608501, 6.636590811800794, 2.576158149609762]

Calculate the global_variances from the covariance matrix.

(%i4) s2 : read_matrix (file_search ("wind.data"))$

(%i5) s : cov1 (s2)$

(%i6) global_variances (s, data=false);
(%o6) [105.3383420606059, 21.06766841212119, 12874.34690469686,
                       113.4651792608501, 6.636590811800794, 2.576158149609762]

cor (matrix)
cor (matrix, logical_value)
The correlation matrix of the multivariate sample.

Option: 'data, default 'true, indicates whether the input matrix contains the sample data, in which case the covariance matrix cov1 must be calculated, or not, and then the covariance matrix (symmetric) must be given, instead of the data.

(%i7) fpprintprec : 7$

(%i8) s2 : read_matrix (file_search ("wind.data"))$

(%i9) cor (s2);
           [    1.0     0.8476338  0.8803515  0.8239623  0.7519506 ]
           [                                                       ]
           [ 0.8476338     1.0     0.8735834  0.6902622  0.782502  ]
           [                                                       ]
(%o9)      [ 0.8803515  0.8735834     1.0     0.7764065  0.8323358 ]
           [                                                       ]
           [ 0.8239623  0.6902622  0.7764065     1.0     0.7293848 ]
           [                                                       ]
           [ 0.7519506  0.782502   0.8323358  0.7293848     1.0    ]

Calculate de correlation matrix from the covariance matrix.

(%i10) s2 : read_matrix (file_search ("wind.data"))$

(%i11) s : cov1 (s2)$

(%i12) cor (s, data=false); /* this is faster */
           [    1.0     0.8476338  0.8803515  0.8239623  0.7519506 ]
           [                                                       ]
           [ 0.8476338     1.0     0.8735834  0.6902622  0.782502  ]
           [                                                       ]
(%o12)     [ 0.8803515  0.8735834     1.0     0.7764065  0.8323358 ]
           [                                                       ]
           [ 0.8239623  0.6902622  0.7764065     1.0     0.7293848 ]
           [                                                       ]
           [ 0.7519506  0.782502   0.8323358  0.7293848     1.0    ]

Posta un commento o usa questo indirizzo per il trackback.

Trackback

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d blogger hanno fatto clic su Mi Piace per questo: