I created a triangular distribution "pd" using the makedist function. The parameters of the triangular pd function are as follows: minimum value = 6, most likely value = 9, maximum value = 20, and n = 200. Then I use the random function with the triangular pd the input argument; i.e., random(myTriangularDist,N,1) to create the data to display in a histogram. Then I use the histogram function to create a histogram of the data. The minimum and the mode of the distribution displayed in the histogram is consistently exactly the same (to 4 decimal places). The result is the same if I change n to 5000. Is this result normal? Also, the median does not approach my most likely value of 9 after I increase n from 200 to 5000. The median remains approximately 11. Is it normal for the median not to approach 9 initially specified as the "most likely value" as n is increased? I would appreciate any comments.
MATLAB: Triangular distribution created using makedist function is the input argument for the random function to create data to use to create a histogram. The minimum and mode values of the histogram are equal. Is this result to be expected?
MATLABtriangular distribution
Related Solutions
doc normcdfdoc normpdf
When you know what you want but not sure the name, try something like
>> lookfor normalrealmin - Smallest positive normalized floating point number.randn - Normally distributed pseudorandom numbers.sprandn - Sparse normally distributed random matrix.surfnorm - Surface normals.isonormals - Isosurface normals.cde - cd elliptic function with normalized complex argument.sne - sn elliptic function with normalized complex argument.addfreqcsmenu - Add a cs menu to switch between linear and normalized frequencyconvertfrequnits - converts between Normalized, Hz, kHz, etchistfit - Histogram with superimposed fitted normal density.jbtest - Jarque-Bera hypothesis test of composite normality.lhsnorm - Generate a latin hypercube sample with a normal distributionlogncdf - Lognormal cumulative distribution function (cdf).lognfit - Parameter estimates and confidence intervals for lognormal data.logninv - Inverse of the lognormal cumulative distribution function (cdf).lognlike - Negative log-likelihood for the lognormal distribution.lognpdf - Lognormal probability density function (pdf).lognrnd - Random arrays from the lognormal distribution.lognstat - Mean and variance for the lognormal distribution.mvncdf - Multivariate normal cumulative distribution function (cdf).mvnpdf - Multivariate normal probability density function (pdf).mvnrnd - Random vectors from the multivariate normal distribution.normcdf - Normal cumulative distribution function (cdf).normfit - Parameter estimates and confidence intervals for normal data.norminv - Inverse of the normal cumulative distribution function (cdf).normlike - Negative log-likelihood for the normal distribution.normpdf - Normal probability density function (pdf).normplot - Displays a normal probability plot.normrnd - Random arrays from the normal distribution.normspec - Plots normal density between specification limits.normstat - Mean and variance for the normal distribution.logn3fit - Fit a 3-param lognormal dist'n using cumulative probabilities.wgtnormfit - Fitting example for a weighted normal distribution.wgtnormfit2 - Fitting example for a weighted normal distribution (log(sigma) parameterization).>>
Judicious search terms help but seeing the list of things related to "normal" lets you find the two functions of interest (plus a lot more depending upon which toolboxes are available, maybe) that might be of use/interest...
There is a ksdensity function that can produce a kernel-smooth density estimate. The issue is that it produces a density (integrates to 1) and the histogram is not a density (bar heights sum to 1). You could figure out the area of the histogram and re-scale the ksdensity values. Alternatively, here's a way to create the histgram, normal curve, and kernel density separately:
x = [randn(100,1); 4+randn(50,1)];[hts,ctrs] = hist(x)bar(ctrs,hts,'hist')area = sum(hts) * (ctrs(2)-ctrs(1))xx = linspace(-3,7);hold on; plot(xx,area*normpdf(xx,mean(x),std(x)),'r-')f = ksdensity(x,xx);plot(xx,area*f,'g-')hold off
Best Answer