# how do I determine the probability distribution of data?

77 views (last 30 days)

Show older comments

##### 0 Comments

### Answers (2)

Richard Willey
on 29 Mar 2012

Sorry if this sounds like a silly question:

Is there an absolute requirement that you describe your data using a parametric distribution? If so why?

As an alternative, would something like the following suffice?

%%Generate some data

X1 = 10 + 5 * randn(200, 1);

X2 = 20 + 8 * randn(250 ,1);

X = [X1; X2];

%%Fit a distribution using a kernel smoother

myFit = fitdist(X, 'kernel')

%%Visualize the resulting fit

index = linspace(min(X), max(X), 1000);

plot(index, pdf(myFit, index))

%%Generate a set of 500 random numbers drawn from the distribution

numbers = random(myFit, 500, 1);

numbers(1:10)

%%Inspect the complete set of methods for myFit

methods(myFit)

##### 4 Comments

Tom Lane
on 13 Apr 2012

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!