Triangledf: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Jeremy
(Importing text file)
 
imported>Bob
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
===Purpose===
===Purpose===
Triangle distribution.
Triangle distribution.
===Synopsis===
===Synopsis===
:prob = triangledf(function,x,a,b,c)
:prob = triangledf(function,x,a,b,c)
===Description===
===Description===
Estimates cumulative distribution function (cumulative, cdf), probability density function (density, pdf), quantile (inverse of cdf), or random numbers for a Triangle distribution.  
Estimates cumulative distribution function (cumulative, cdf), probability density function (density, pdf), quantile (inverse of cdf), or random numbers for a Triangle distribution.  
This distribution is usually used for rough models of data and is triangular in shape (hence the name).
This distribution is usually used for rough models of data and is triangular in shape (hence the name).
 
 
INPUTS:
 
* function =  [ {'cumulative'} | 'density' | 'quantile' | 'random' ], defines the functionality to be used. Note that the function recognizes the first letter of each string so that the string could be: [ 'c' | 'd' | 'q' | 'r' ].
::<math>f(x)= \frac {2 \left ( x-a \right ) } {\left ( b-a \right ) \left ( c-a \right ) } \mathrm {I} \left ( a \le x \le c \right ) + \frac {2 \left (b-x \right ) } { \left ( b-a \right ) \left ( b-c \right ) } \mathrm {I} \left (c \le x \le b \right )</math>
* x = matrix in which the sample data is stored (-inf,inf).  
 
quantile - interval (0,1).
 
random - vector indicating the size of the random matrix to create.
 
* a = "min" parameter (real, <= mode).
::<math>F(x)= \frac { \left ( x-a \right ) ^2} {\left ( b-a \right ) \left ( c-a \right ) } \mathrm {I} \left ( a \le x \le c \right ) + 1 - \frac { \left (b-x \right )^2 } { \left ( b-c \right ) \left ( c-a \right ) } \mathrm {I} \left (c \le x \le b \right )</math>
*  b = "max" parameter (real, >= mode).
 
*  c = "mode" parameter (real, >= min and <=max).
 
 
 
====Inputs====
 
* '''function''' =  [ {'cumulative'} | 'density' | 'quantile' | 'random' ], defines the functionality to be used. Note that the function recognizes the first letter of each string so that the string could be: [ 'c' | 'd' | 'q' | 'r' ].
 
* '''x''' = matrix in which the sample data is stored (-inf,inf).  
:: for function = 'quantile' - interval (0,1).
:: for function = 'random' - vector indicating the size of the random matrix to create.
 
* '''a''' = "min" parameter (real, <= mode).
'''b''' = "max" parameter (real, >= mode).
'''c''' = "mode" parameter (real, >= min and <=max).
 
'''Note''': If inputs (x, a, b, and c) are not equal in size, the function will attempt to resize all inputs to the largest input using the RESIZE function.  
'''Note''': If inputs (x, a, b, and c) are not equal in size, the function will attempt to resize all inputs to the largest input using the RESIZE function.  
'''Note''': Functions will typically allow input values outside of the acceptable range to be passed but will convert them to NaN.
'''Note''': Functions will typically allow input values outside of the acceptable range to be passed but will convert them to NaN.
===Examples===
===Examples===
====Cumulative:====
 
====Cumulative====
<pre>
>> prob = triangledf('c',2,1,3,2)
>> prob = triangledf('c',2,1,3,2)
prob =
prob =
Line 25: Line 49:
>> x    = [0:0.1:10];
>> x    = [0:0.1:10];
>> plot(x,triangledf('c',x,1,3,2),'b-',x,triangledf('c',x,1,5,3),'r-')
>> plot(x,triangledf('c',x,1,3,2),'b-',x,triangledf('c',x,1,5,3),'r-')
====Density:====
</pre>
====Density====
<pre>
>> prob = triangledf('d',2,1,3,2)
>> prob = triangledf('d',2,1,3,2)
prob =
prob =
Line 31: Line 57:
>> x    = [0:0.1:10];
>> x    = [0:0.1:10];
>> plot(x,triangledf('d',x,0,3,0),'b-',x,triangledf('d',x,1,3,2),'r-')
>> plot(x,triangledf('d',x,0,3,0),'b-',x,triangledf('d',x,1,3,2),'r-')
====Quantile:====
</pre>
====Quantile====
<pre>
>> prob = triangledf('q',0.5,1,3,2)
>> prob = triangledf('q',0.5,1,3,2)
prob =
prob =
     2.0000
     2.0000
====Random:====
</pre>
====Random====
<pre>
>> prob = triangledf('r',[4 1],1,3,2)
>> prob = triangledf('r',[4 1],1,3,2)
ans =
ans =
Line 42: Line 72:
     2.1094
     2.1094
     2.2585
     2.2585
</pre>
===See Also===
===See Also===
[[betadr]], [[cauchydf]], [[chidf]], [[expdf]], [[gammadf]], [[gumbeldf]], [[laplacedf]], [[logisdf]], [[lognormdf]], [[normdf]], [[paretodf]], [[raydf]], [[unifdf]], [[weibulldf]]
 
[[betadf]], [[cauchydf]], [[chidf]], [[expdf]], [[gammadf]], [[gumbeldf]], [[laplacedf]], [[logisdf]], [[lognormdf]], [[normdf]], [[paretodf]], [[raydf]], [[unifdf]], [[weibulldf]]

Latest revision as of 07:46, 10 October 2008

Purpose

Triangle distribution.

Synopsis

prob = triangledf(function,x,a,b,c)

Description

Estimates cumulative distribution function (cumulative, cdf), probability density function (density, pdf), quantile (inverse of cdf), or random numbers for a Triangle distribution.

This distribution is usually used for rough models of data and is triangular in shape (hence the name).





Inputs

  • function = [ {'cumulative'} | 'density' | 'quantile' | 'random' ], defines the functionality to be used. Note that the function recognizes the first letter of each string so that the string could be: [ 'c' | 'd' | 'q' | 'r' ].
  • x = matrix in which the sample data is stored (-inf,inf).
for function = 'quantile' - interval (0,1).
for function = 'random' - vector indicating the size of the random matrix to create.
  • a = "min" parameter (real, <= mode).
  • b = "max" parameter (real, >= mode).
  • c = "mode" parameter (real, >= min and <=max).

Note: If inputs (x, a, b, and c) are not equal in size, the function will attempt to resize all inputs to the largest input using the RESIZE function.

Note: Functions will typically allow input values outside of the acceptable range to be passed but will convert them to NaN.

Examples

Cumulative

>> prob = triangledf('c',2,1,3,2)
prob =
    0.5000
>> x    = [0:0.1:10];
>> plot(x,triangledf('c',x,1,3,2),'b-',x,triangledf('c',x,1,5,3),'r-')

Density

>> prob = triangledf('d',2,1,3,2)
prob =
    1.0000
>> x    = [0:0.1:10];
>> plot(x,triangledf('d',x,0,3,0),'b-',x,triangledf('d',x,1,3,2),'r-')

Quantile

>> prob = triangledf('q',0.5,1,3,2)
prob =
    2.0000

Random

>> prob = triangledf('r',[4 1],1,3,2)
ans =
    2.2817
    1.9431
    2.1094
    2.2585

See Also

betadf, cauchydf, chidf, expdf, gammadf, gumbeldf, laplacedf, logisdf, lognormdf, normdf, paretodf, raydf, unifdf, weibulldf