Posts Tagged ‘ matrix ’

Basics on Markov Chain (for parents)

December 20, 2011
By
Basics on Markov Chain (for parents)

Markov chains is a very interesting and powerful tool. Especially for parents. Because if you think about it quickly, most of the games our kids are playing at are Markovian. For instance, snakes and ladders... It is extremely easy to write down th...

Read more »

Dealing with Non-Positive Definite Matrices in R

November 27, 2011
By
Dealing with Non-Positive Definite Matrices in R

Last time we looked at the Matrix package and dug a little into the chol(), Cholesky Decomposition, function.  I noted that often in finance we do not have a positive definite (PD) matrix.  The chol() function in both the Base and Matrix...

Read more »

Once you’re comfortable with 2-arrays and 2-matrices, you…

October 15, 2011
By
Once you’re comfortable with 2-arrays and 2-matrices, you…

Once you’re comfortable with 2-arrays and 2-matrices, you can move up a dimension or two, to 4-arrays or 4-tensors. You can move up to a 3-array / 3-tensor just by imagining a matrix which “extends back into the blackboard”. Like a 5 × 5 ma...

Read more »

Le Monde puzzle [#738]

September 1, 2011
By
Le Monde puzzle [#738]

The Friday puzzle in Le Monde this week is about “friendly perfect squares”, namely perfect squares x2>10 and y2>10 with the same number of digits and such that, when drifting all digits of x2 by the same value a (modulo 10), one recovers y2. For instance, 121 is “friend” with 676. Here is my...

Read more »

Example 9.1: Scatterplots with binning for large datasets

July 5, 2011
By
Example 9.1: Scatterplots with binning for large datasets

Scatterplots can get very hard to interpret when displaying large datasets, as points inevitably overplot and can't be individually discerned. A number of approaches have been crafted to help with this problem. One approach uses binning. This approa...

Read more »

Summarize Data by Several Variables

May 23, 2011
By
Summarize Data by Several Variables

Here's an example how to conveniently summarize data with the cast function (package reshape). By the way you see how this could be done "in-conveniently" by hand. You also see how a for-loop works and how a matrix is constructed and fill...

Read more »

Block diagonal matrices in R

April 13, 2011
By
Block diagonal matrices in R

As far as I can tell, R doesn’t have a function for building block diagonal matrices so as I needed one, I’ve coded it myself. It might save someone some time. Example: Let m1 and m2 two square matrices. Selec … Continue reading

Read more »

Hierarchial Cluster Analysis

November 25, 2010
By
Hierarchial Cluster Analysis

With the distance matrix found in previous tutorial, we can use various techniques of cluster analysis for relationship discovery. For example, for the data set mtcars, we can use the hclust method with the distance matrix and plot a dendrogram that ...

Read more »

Example 7.31: Contour plot of BMI by weight and height

April 5, 2010
By
Example 7.31: Contour plot of BMI by weight and height

A contour plot is a simple way to plot a surface in two dimensions. Lines with a constant Z value are plotted on the X-Y plane.Typical uses include weather maps displaying "isobars" (lines of constant pressure), and maps displaying lines of constant e...

Read more »

Sorting a matrix/data.frame on a column

October 30, 2009
By
Sorting a matrix/data.frame on a column

mat.sort <- function(mat,n) { mat),] <- mat return(mat) } a <- matrix(rnorm(100),ncol=10) mat.sort(a,1)

Read more »

Sponsors