Re: Re: equiprobable intervals with triangular pdf
- To: mathgroup at smc.vnet.net
- Subject: [mg41537] Re: Re: equiprobable intervals with triangular pdf
- From: "Ian McInnes" <ian at whisper-wood.co.uk>
- Date: Mon, 26 May 2003 05:46:18 -0400 (EDT)
- References: <baiar6$dks$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I posted a response to the original query several days ago, but since installing a proxy, my posts don't appear to go any farther than my local loopback. My apologies for any inconvenience this delay has caused. I believe this may clarify the subject, and also makes available my code to support other distributions. Original Post------------------------------------------------ The PDF should be defined using the UnitStep function to allow it to be integrated symbolically. Thus the PDF on x for a general triangular distribution with lower limit a, upper limit b and mode c is: (2*(((a - x)*UnitStep[c - x])/(a - c) + ((b - x)*UnitStep[-c + x])/ (b - c)))/(-a + b) The CDF on x for these parameters can then be found as: (((a - x)^2*UnitStep[c - x])/(a - c) + ((a*(b - c) + b*c - 2*b*x + x^2)*UnitStep[-c + x])/ (b - c))/(a - b) The Quantile on q is: If[q <= (c-a)/(b-a), a + Sqrt[q(b-a)(c-a)], b - Sqrt[(1-q)(b-a)(b-c)] ] If you want use this distribution on a regular basis, the best approach is to add it to the add-on package named ContinuousDistributions.m (with backup provision) so that it can be used in just the same flexible way as the existing distributions. I have added a number of distributions to this file, including the triangular distribution, plus a few other enhancements. I am concerned about possible copyright violations if I make the whole file available, therefore I am supplying a file with details of how to apply the enhancements. This contains only code that I have added: http://www.whisper-wood.co.uk/Mathematica/Enhancements/ContinuousDistributio ns.txt ------------------------------------------------------------- Using the code from the above link: In[1]:= ?TriangularDistribution TriangularDistribution[a, b, c] represents the triangular distribution with minimum value a, maximum value b and mode c. In[2]:= distn = TriangularDistribution[a, b, c]; In[3]:= Parameters[distn] Out[3]= {-Infinity < a < c, c < b < Infinity, a < c < b} In[4]:=Quantile[distn, 1] Out[4]= If[1 <= (-a+c)/(-a+b), a+Sqrt[(b-a)(c-a)],b-Sqrt[(1-1)(b-a)(b-c)]] In[5]:= Simplify[%, Parameters[distn]] Out[5]= b Note the use of the Parameters function to simplify the If expressions giving the quantile (I am not sure why Mathematica does not automatically simplify the sub-expression (1-1) ). NB: Texts give the mode as lying strictly between the minimum and maximum endpoints, thus providing a valid PDF and avoiding the problems that arise if the mode is allowed to be the same as one of the endpoints. Apart from the link above containing numerous distributions, I also appended the code for the triangular distribution to a previous post: http://groups.google.com/groups?q=insubject:Triangular+insubject:Probability +insubject:Distributions+author:Ian+author:McInnes&hl=en&lr=&ie=UTF-8&oe=UTF -8&selm=9jis20%24ch%241%40smc.vnet.net&rnum=1 Hope this helps, Ian McInnes.