Questions tagged [matlab]

A programming language/environment. Use this tag for any on-topic question that (a) involves MATLAB either as a critical part of the question or expected answer, & (b) is not just about how to use MATLAB .

MATLAB is a high-level language and interactive programming environment developed by MathWorks. It is the foundation for a number of other tools related to statistical analysis, including Statistics Toolbox, Optimization Toolbox, Curve Fitting Toolbox and Neural Network Toolbox.

Some informative links that show up quite often in answers:

1258 questions
45
votes
4 answers

How to interpret mean of Silhouette plot?

Im trying to use silhouette plot to determine the number of cluster in my dataset. Given the dataset Train , i used the following matlab code Train_data = full(Train); Result = []; for num_of_cluster = 1:20 centroid =…
Learner
  • 4,007
  • 11
  • 37
  • 39
24
votes
3 answers

How can I generate data with a prespecified correlation matrix?

I’m trying to generate correlated random sequence with mean = $0$, variance = $1$, correlation coefficient = $0.8$. In the code below, I use s1 & s2 as the standard deviations, and m1 & m2 as the means. p = 0.8 u = randn(1, n) v = randn(1, n) x =…
anisa
  • 241
  • 1
  • 2
  • 3
23
votes
2 answers

How to test equality of variances with circular data

I am interested in comparing the amount of variability within 8 different samples (each from a different population). I am aware that this can be done by several methods with ratio data: F-test equality of variance, Levene test, etc. However, my…
Alex Williams
  • 231
  • 2
  • 3
21
votes
4 answers

Generate random numbers following a distribution within an interval

I need to generate random numbers following Normal distribution within the interval $(a,b)$. (I am working in R.) I know the function rnorm(n,mean,sd) will generate random numbers following normal distribution,but how to set the interval limits…
dvs
  • 313
  • 1
  • 2
  • 7
20
votes
3 answers

How is $\theta$, the polar coordinate, distributed when $(x,y) \sim U(-1,1) \times U(-1,1)$ vs. when $(x,y) \sim N(0,1)\times N(0,1)$?

Let the Cartesian $x,y$ coordinates of a random point be selected s.t. $(x,y) \sim U(-10,10) \times U(-10,10)$. Thus, the radius, $\rho = \sqrt{x^2 + y^2}$, isn't uniformly distributed as implied by $\rho$'s p.d.f. Nonetheless I would expect…
19
votes
4 answers

k-means implementation with custom distance matrix in input

Can anyone point me out a k-means implementation (it would be better if in matlab) that can take the distance matrix in input? The standard matlab implementation needs the observation matrix in input and it is not possible to custom change the…
Eugenio
  • 311
  • 1
  • 2
  • 5
18
votes
3 answers

Among Matlab and Python, which language is good for statistical analysis?

Among Matlab and Python, which language is good for general statistical data analysis? What are the pros and cons, other than accessibility, for each?
user1102
18
votes
2 answers

Best way to perform multiclass SVM

I know that the SVM is a binary classifier. I would like to extend it to multi-class SVM. Which is the best, and maybe the easiest, way to perform it? code: in MATLAB u=unique(TrainLabel); N=length(u); if(N>2) itr=1; …
lakshmen
  • 1,045
  • 4
  • 12
  • 26
17
votes
3 answers

Estimating Markov transition probabilities from sequence data

I have a full set of sequences (432 observations to be precise) of 4 states $A-D$: eg $$Y=\left(\begin{array}{c c c c c c c} A& C& D&D & B & A &C\\ B& A& A&C & A&- &-\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ B& C& A&D & A & B & A\\ …
HCAI
  • 737
  • 2
  • 7
  • 23
17
votes
1 answer

Non-uniform distribution of p-values when simulating binomial tests under the null hypothesis

I heard that under the null hypothesis the p-value distribution should be uniform. However, simulations of binomial test in MATLAB return very different-from-uniform distributions with mean larger than 0.5 (0.518 in this case): coin = [0…
16
votes
2 answers

Correlation coefficient between a (non-dichotomous) nominal variable and a numeric (interval) or an ordinal variable

I've already read all the pages in this site trying to find the answer to my problem but no one seems to be the right one form me... First I explain you the kind of data I'm working with... Let's say that I have an array vector with several names of…
15
votes
4 answers

Gaussian Processes: How to use GPML for multi-dimensional output

Is there a way to perform Gaussian Process Regression on multidimensional output (possibly correlated) using GPML? In the demo script I could only find a 1D example. A similar question on CV that tackles case of multidimensional input. I went…
15
votes
1 answer

Generating values from a multivariate Gaussian distribution

I am currently trying to simulate values of a $N$-dimensional random variable $X$ that has a multivariate normal distribution with mean vector $\mu = (\mu_1,...,\mu_N)^T$ and covariance matrix $S$. I am hoping to use a procedure similar to the…
14
votes
2 answers

How to perform cross-validation for PCA to determine the number of principal components?

I'm trying to write my own function for principal component analysis, PCA (of course there's a lot already written but I'm just interested in implementing stuff by myself). The main problem I encountered is the cross-validation step and calculating…
Kirill
  • 622
  • 1
  • 7
  • 15
14
votes
5 answers

Reversible jump MCMC code (Matlab or R)

Does anyone know of some well written code (in Matlab or R) for reversible jump MCMC? Preferably a simple demo application to compliment papers on the subject, that would be useful in understanding the process.
Nick
  • 3,327
  • 6
  • 28
  • 24
1
2 3
83 84