2010-04-30

Principle of Random Permutation

You may use 'sample' function in R, and it is sufficient usually.
The following is one of my favoriate code. Here it is expressed in R language.

# R coding showing the principle of random permutation
RanPermute <- function(n)
{
    x <- cbind(1:n, runif(n))
    return(x[order(x[,2]),1])
}

# Test code
RanPermute(100)

2010-04-23

Linear Solution of a Real Symmetic Matrix

See this PDF file for the R script.

Inverse of a Real Symmetric Matrix using LDL' Transformation (Factorization, Decomposition)

See this PDF file for the R script.

Determinant of a Real Symmetric Matrix using LDL' Transformation (Factorization, Decomposition)

See this PDF file for the R script.

LDL' Transformation (Factorization, Decomposition)

See this PDF file for the R script.

Cholesky Decomposition

See this PDF file for the R script.

See this MS-Excel file for a case of manual calculation.

Cholesky decomposition is only valid for positive definite matrix.
It may be used to test if a matrix is positive definite.
NONMEM use this for the transformation of omega and sigma matrix into unconstrained parameter (UCP). UCP is previously called STP(scaled transformed parameter).
For the inversion of hessian or linear system solution, LDL' transformation is more useful.
During the minimization process we cannot guarantee that hessian matrix is positive definite but which is always symmetric.
LDL' transformation can be used always for any real symmetric matrix.

R Script for Matrix Algebra Textbook

See this PDF file.

2010-04-19

Basic Math - Special and Distribution Functions

See this PDF file. (R script eliminated due to possible copyright issue.)

"Special" includes
gamma,
beta,
incomplete gamma and its inverse,
incomplete beta and its inverse.

"Distribution" includes
normal, lognormal,
gamma,
chi-square,
beta,
t- (central and non-central)
F-,
binomial,
and poisson distributions.

Basic Stat - Chapter 7 Estimation

R Script file for the examples.

2010-04-12