Return to Code Examples

Randomly sampled TTest comparison

The following code has been used to compare couples of vectors in a given structure composed of 4×12 cells which result from simulated results of 4×12 model genotypes (download archive here). Most vectors have a similar dimension (175), but some differ, requiring a multiple random comparison by permutation. The final distribution of the p-values (reported in the four subplots) provides an indication of likelihood of statistical significant difference.

The first part of the code loads the data structure, then generates two random vectors (randperm) that are used to create the permutation of the target data to compare (which are selected assigning a value between 1 and 12 to the parameters el1 and el2). The operation is repeated n time (default: 500) to allow multiple (n) permutations.

The second part of the code is used to provide instructions for a series of charts. This is meant to show how to change some basic settings such as color of the histograms, axis range, histogram edge etc. By assigning the output of the function histogram to a variable (default: fig), it is possible to display the content of this variable and access the function names assigned by Matlab which are used to specify further plotting settings. E.g.:

fig = 1
Histogram with properties:

Data: [500×1 double]
Values: [3 3 10 22 27 34 27 30 26 28 38 26 38 28 29 30 33 41 27]
NumBins: 19
BinEdges: [1×20 double]
BinWidth: 0.0500
BinLimits: [0.0500 1]
Normalization: ‘count’
FaceColor: [0.8000 0.2000 0.6000]
EdgeColor: [0.8000 0.2000 0.2000]

examplehistograms

 

 

Insert math as
Block
Inline
Additional settings
Formula color
Text color
#333333
Type math using LaTeX
Preview
\({}\)
Nothing to preview
Insert
%d bloggers like this: