How to create normal distribution with positive integers in matlab with bell shape graph?
Show older comments
From the scripts below, the cracks were distributed randomly in the rock formation with dimensions of 200x200. The crack density is estimated from the scripts and the histograms of crack density and final crack lengths are plotted. My task is to distribute the cracks not randomly but probabilistically with normal distribution. I have edit the rand code in matlab to randn (which normally distributes the random numbers). Since in matlab normal distribution using positive and negative integers, the negative integers were eliminated with abs code which uses only absolute integers via converting negative integers to positive since I cannot have negative cracks.
t = 0.2 + 0.1.*randn(L,L);
r = abs(t);
z = r<porosity;
The 0.2 and 0.1 are referred as mean and standard deviation so I made them up in order to get bell shaped distribution. For normal distribution, the graph should be bell shaped but from the edited scripts I am getting half of the bell shape and it is not evenly distributed as it normally distributes. Is there any ways of getting normal distribution with bell shape?
6 Comments
dpb
on 4 Apr 2017
What is
z = r<porosity;
intended to compute? It will be a logical array of those positions that satisfy the equality; the choice of z as variable name makes me suspect you have something else in mind???
The distribution of abs(randn(u,s)) will be somewhat bell-shaped but will be much more centered towards the mean than a normal as you're "doubling up" the probabilities of each percentage in the range [0,z] over what it is in actual normal since -z and +z are now the same point.
I would suggest you need to use something other than a normal for the underlying distribution; I don't know the particular field of investigation but I'd presume there likely are candidate distributions in the literature that have been used for the purpose; I'd suggest doing some searches there for same.
Aukhat Uap
on 5 Apr 2017
Edited: Aukhat Uap
on 5 Apr 2017
dpb
on 5 Apr 2017
Well, if you truncate a lognormal it won't look much like a lognormal shape (and won't be, either). While I didn't dig into the above reference and certainly not the cites that I elided that were the references, I'd presume they used the parameters of the distributions to model the variable rather than trying to doctor up (for lack of better words at the moment) the result. To plot, look at
doc ecdhist
examples; first is a truncated exponential that is similar in what you've tried but if you truncate excessively the results won't look much like lognormal 'cuz it'll be the tail you'll eliminate...
Aukhat Uap
on 5 Apr 2017
Typo, sorry...there's an 'f' missing--
ecdfhist % Emprical CDF Histogram function (Statistics Toolbox)
Regular old }hist| will work; if it doesn't show the tails, not large enough sample size or number of bins is probably the cause; increase both.
I gotta' meeting in town, gotta' run...
ADDENDUM
OK, am back...here's example of what was alluding to--

Three histograms of lognrnd, first two with 100 samples but default 10 then 20 bins (red/cyan outlines, respectively), then 1000 samples and 50 bins (white). The shape improves with resolution and number of samples altho is a long tail for even the lower; that's just what lognormal does. How much depends on the shape factor, of course.
Image Analyst
on 6 Apr 2017
Can you post an image of your cracks to help us better visualize it? Also, do you have the Statistics and Machine Learning Toolbox? And, FYI, you might look at RANDRAW: http://www.mathworks.com/matlabcentral/fileexchange/7309-randraw
Answers (1)
Gargle is your friend... :)
has a list of a half-dozen candidate distributions with references to previous validations of their appropriateness.
Suitability and use of different PDFs to characterize the
statistical variation of fracture geometrical parameters.
PDF Length Orientation Location
Normal No Yes No
Lognormal Yes No No
Exponential Yes No No
Power law Yes No No
Fisher No Yes No
Poisson No No Yes
These were in light of some Monte Carlo study methods; I've no idea if has any bearing to your problem but just from a "reasonableness" of physical characteristics I can see reasons for the choices above, particularly for throwing out the normal as a length distribution for the problems you have if nothing else.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!