I am wondering how, in Matlab, to plot a continuous pdf with the following information?
mean=-0.3731
standard deviation= 5.6190
skewness=-3.0003
kurtosis=13.1722
or alternative how do I plot a continous pdf that is not normal? (like it is skewness and has kurtosis, etc)
Thanks!
Those parameters don't define a distribution, but normally you would use "makedist" in matlab to generate a probability distribution object and then plot it.
The following thread has some discussion on defining a distribution. How to generate distributions given, mean, SD, skew and kurtosis in R?
Based on your comment below, I think you are looking for something like the following functio that generates a m by n matrix of random values with the following parameters:
r = pearsrnd(mu,sigma,skew,kurt,m,n)
Related
I am trying to obtain an equation for a function fitted to some histogram data, I was thinking of trying to do this by fitting a rational function as the data doesn't resemble any distribution recognisable by myself.
The data is experimental, and I want to be able to generate a random number according to its distribution. Hence I am hoping to be able to fit it to some sort of PDF from which I can obtain a CDF, which can be rearranged to a function into which a uniformly distributed random number between 0 and 1 can be substituted in order to obtain the desired result.
I have attempted to use the histfit function, which has worked but I couldn't figure out how to obtain an equation for the curve it fitted. Is there something stupid I have missed?
Update: I have discovered the function rationalfit, however I am struggling to figure out what the inputs need to be.
Further Update: Upon exploring the histfit command further I have discovered the option to fit it to a kernal, the figure for which looks promising, however I am only able to obtain a set of x and y values for the curve, not its equation as a I wanted.
From the documentation on histfit:
Algorithms
histfit uses fitdist to fit a distribution to data. Use fitdist
to obtain parameters used in fitting.
So the answer to your question is to use fitdist to get the parameters you're after. Here's the example from the documentation:
rng default; % For reproducibility
r = normrnd(10,1,100,1);
histfit(r)
pd = fitdist(r,'Normal')
pd =
NormalDistribution
Normal distribution
mu = 10.1231 [9.89244, 10.3537]
sigma = 1.1624 [1.02059, 1.35033]
Working in Matlab...
I have a long vector of data vec that I want to make a Q-Q plot of against a Student-t distribution for various values of t. I know qqplot(vec) produces a plot against a normal distribution. I know from here that I can use other distributions by inserting them as a second parameter qqplot(vec,dis).
I can make other distributions with makedist (see mathworks.com/help/stats/makedist.html) but Student-t isn't an option there that I can see. There are the functions tpdf, tcdf etc. about Student-t (see http://www.mathworks.com/help/stats/students-t-distribution-1.html) but how do I use them to make a distribution item to use in the Q-Q plot? Or is there another technique to get the plot I want?
I haven't used Matlab in about a decade, so I can't give specific syntax. That said, if vec has length n you should be able to create a vector of t-values corresponding to quantiles i / (n+1) for i=1,...,n using tinv. Then do a qqplot of vec vs. the t-vector.
I'm trying to fit a multivariate normal distribution to data that I collected, in order to take samples from it.
I know how to fit a (univariate) normal distribution, using the fitdist function (with the 'Normal' option).
How can I do something similar for a multivariate normal distribution?
Doesn't using fitdist on every dimension separately assumes the variables are uncorrelated?
There isn't any need for a specialized fitting function; the maximum likelihood estimates for the mean and variance of the distribution are just the sample mean and sample variance. I.e., compute the sample mean and sample variance and you're done.
Estimate the mean with mean and the variance-covariance matrix with cov.
Then you can generate random numbers with mvnrnd.
It is also possible to use fitmgdist, but for just a multivariate normal distribution mean and cov are enough.
Yes, using fitdist on every dimension separately assumes the variables are uncorrelated and it's not what you want.
You can use [sigma,mu] = robustcov(X) function, where X is your multivariate data, i.e. X = [x1 x2 ... xn] and xi is a column vector data.
Then you can use Y = mvnpdf(X,mu,sigma) to get the values of the estimated normal probability density function.
https://www.mathworks.com/help/stats/normfit.html
https://www.mathworks.com/help/stats/mvnpdf.html
In Matlab I've got a binomial PDF already defined where the set of possible events are 0-255. I would like to generate symbols, from 0-255, according to that PDF. How can I do that?
This is the code used in order to generate the PDF:
x=0:255; %range of possible values
m=255;
b=0.06245;
y=binopdf(x,m,b); %generates a binomial distribution
When plotting "y" I can see that most of the times the symbol that the source will generate will be between 9 to 23. Again, how can I design that symbol source? Thank you.
Use
result = binornd(m,b,R,C);
to generate an R x C matrix of random values drawn from an (m,b) binomial distribution.
If you then plot the histogram
hist(result(:),-.5:255.5)
you can check that (for R and/or C large enough) the obtained values follow the desired binomial distribution.
Can anyone explain to me how to generate the Weibull distribution parameters k and c, in Matlab?
I have a file of 8000 data of wind speed, and I'd like to do the following:
Generate the Weibull's k and c parameters of those.
Plot the probability density function against the wind speed.
I am new in Matlab and have not yet been able to do this.
If you have the Statistics toolbox, you can use fitdist:
pd = fitdist(x,'Weibull')
where x is your data. I'm guessing it should return the parameters a and b in:
You can then calculate the pdf (and plot it) using the pdf function. There are some examples (albeit for a normal distribution) in the documentation for fitdist.