# 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 .

141 questions
Filter by
Sorted by
Tagged with
25k views

### 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 ...
• 193
39k views

### 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 ...
• 341
2k views

### 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 ...
• 425
3k views

### Cross-validation techniques for time series data

What is an appropriate cross-validation technique for time series data? I have a daily 4 years time series data and fitting a SVM model by MATLAB R2015b: ...
• 4,271
28k views

### 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 & ...
• 271
22k views

### 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 ...
• 5,085
13k views

### Normalizing a 2D-histogram and getting the marginals

I have a 2D-histogram for two vectors, s1 and s2, generated using the hist3 function in Matlab: [hist2D, binC] = hist3([s1' s2']); I am normalizing it by making ...
• 591
23k views

### 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 ...
• 652
3k views

### The effect of the number of samples in different cells on the results of ANOVA

I have written a 3-way ANOVA in C++. I have 3 factors, lets say A, B and C and my aim is to check the strength of all possible interactions and main effects. The result of my code is the same as in ...
• 427
3k views

### How to compute PCA scores from eigendecomposition of the covariance matrix?

Given a data matrix $\mathbf X$ of $12 \times 7$ size with samples in rows and variables in columns, I have calculated centered data $\mathbf X_c$ by subtracting column means, and then computed ...
107k views

### 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 ...
• 4,477
118k views

### 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 ...
• 323
18k views

### 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 ...
• 1,133
8k views

### How to compare two or more correlation matrices?

I have $P$ correlation matrices $(n \times n)$ computed with $P$ sets of $(m \times n)$ data (observed) using the MATLAB function corrcoef. How do I compare and ...
• 243
11k views

### How can I draw a value randomly from a kernel density estimate?

I have some observations, and I want to mimick sampling based on these observations. Here I consider a non-parametric model, specifically, I use kernel smoothing to estimate a CDF from the limited ...
• 543
3k views

### Strange outcome when performing nonlinear least squares fit to a power law

I have a data set (given below in my MATLAB code) y vs. x and my eventual goal is to fit it to a power law $y=ax^b$ to see what exponent $b$ I get. I did some non-linear least squares fitting and ...
• 629
1k views

### Do we always assume cross entropy cost function for logistic regression solution unless stated otherwise?

I am using Matlab glmfit for logistic regression. Now I know that usually people use the cross entropy to evaluate the error in predictions against the true labels ( which different than the linear ...
• 133
7k views

### Confidence interval for cross-validated classification accuracy

I'm working on a classification problem that computes a similarity metric between two input x-ray images. If the images are of the same person (label of 'right'), a higher metric will be calculated; ...
• 113
6k views

### QQ Plot Reference Line not 45°

I was plotting (standardized) return data with qqplot() in MATLAB against the theoretical quantiles of a normal distribution. However, the line in the QQ-Plot does ...
• 545
5k views

### Confused by MATLAB's implementation of ridge

I have two different implementations of ridge in MATLAB. One is simply $\mathbf x = (\mathbf{A}'\mathbf{A}+\mathbf{I}\lambda)^{-1}\mathbf{A}'\mathbf b$ (as seen ...
• 81
5k views

• 591
1 vote
2k views

### Generate t distributed random variable in matlab

How can we generate t distributed random variables with given mean and covariance in matlab. trnd is a function in matlab but we can get random variable with different degrees of freedom but how to ...
• 463
1 vote