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-30
2010-04-25
2010-04-24
Some Other Random Deviates Generation
Some Other Random Deviates (exponential, gamma, beta) Generation are demonstrated.
See this PDF file for the R script.
See this PDF file for the R script.
Random Normal Deviates using Random Uniform Deviates
Random number from normal distribution (Random Normal Deviates) can be generated from random uniform deivates.
See this PDF file for the R script.
See this PDF file for the R script.
Random Number from Uniform Distribution
See this PDF file for the Visual Studio C# .NET progam.
Random number from the uniform [0,1) distribution (Random Uniform Deviates) are the base for all other random deviates.
Random number from the uniform [0,1) distribution (Random Uniform Deviates) are the base for all other random deviates.
2010-04-23
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.
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.
2010-04-22
2010-04-21
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.
"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
Subscribe to:
Posts (Atom)