Triangular random numbersThis simple m-file generates discrete random numbers from a triangular distribution.
The distribution is defined by:
- a minimum and a maximum value
- a "top" value, with the highest probability.
The output is a matrix containing NxM random integers.
Version and downloadVersion 2.0 - Release 20.10.04 [Legal Stuff]
Download the function as a .m matlab file (3 Kb).
Limitations/PrerequisitesThis is a numeric approximation, so use with care in "serious" statistical applications! It does necessitate Matlab and the statistical toolbox.
- Two different algorithms are implemented. One is efficient for large number of random points within a small range (maxVal-minVal), while the other is efficient for large range for reasonable number of points. For large ranges, there is a O(n2) relation with regard to the product of range * number_of_points. When this product reach about a billion, the runtime reach several minutes.
- To inspect the resulting distribution, plot a histogram of the
resulting random numbers, e.g. "
Legal blahblah & Conditions of use
© CSE - L.Cavin, 2003, 2004
These libraries and functions (THE PROGRAM) are provided "as is" without warranty, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with the person downloading or running the program (THE USER). Should the program prove defective, the user assumes the cost of all necessary servicing, repair or correction.
In no event will the Author or the Copyright holder be liable to the user for damages, including any general, special, incidental or consequential damages arising out of the use, peruse or inability to use the program (including, but not limited to loss of data or data being rendered inaccurate or losses sustained by the user or third parties or a failure of the program to operate with any other programs), even if the Author or the Copyright holder has been advised of the possibility of such damages.
The fact of downloading or running the program implies acceptation of the present liability limitation by the user.
These libraries and functions are free to use for non-commercial purposes and can be distributed (free of charge) as long as the copyrights notices are kept intact. In particular, if the program is distributed further by the user, the user is responsible for including this legal warning and liability limitation to the distribution.
It is also encouraged to improve these functions; please send to the author any improvements - we may want to include them in this distribution under the same conditions.
Do not be afraid, I am confident that the program will work - without warranties of course ;-)
Thanks to the Free Software Foundation for inspiring this nice little legal blahblah... My favorite part is the "inability to use"... even if the "general, special, incidental or consequential" part is also quite fun!