How to do normalize distribution technique on a simple matrix?

2 views (last 30 days)
This is just a practice about normal distribution in MATLAB and not a real project.
I created a simple matrix and want to test normal distribution on it, it's
x=[1 2 3 4 5 6 7 8 9 10 11 12 13 16 18 20 800 801 802 803 810 850]';
After that I used 'distributionFitter' Toolbox in MATLAB and plot it and as you can see it has not a normal distribution:
nd.png
I was reading MATLAB help and found these codes:
pd = fitdist(x,'Normal');
%I change this code to have a same x_values vs x
x_values = linspace(min(x), max(x), size(x,1));
y = pdf(pd,x_values);
It works but I'm so confused about which variable is my final data? I mean I'm looking for a data who has been normal distribution?
If my codes are wrong how can I convert x to a matrix with normal distribution?

Accepted Answer

Image Analyst
Image Analyst on 2 Dec 2019
Try this:
pd = fitdist(x, 'Normal')
% Get 1000 random numbers from this distribution:
r = pd.sigma * randn(1000) + pd.mu;
% View the histogram so we'll see that it has a normal shape.
histogram(r)
grid on;
  2 Comments
motevalizadeh
motevalizadeh on 2 Dec 2019
sorry if my question is simple or..., you mean r is my new data with normal distribution?
Image Analyst
Image Analyst on 2 Dec 2019
Yes. Isnt' that what you wanted? To generate some new values as if they were taken from the same process that generated your training data? The new random values, r, will be normally distributed as you can see from the histogram.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!