DistributionView

The DistributionView software is a simulator that works by writing mathematical expressions width distributions. It allows graphic visualization of series, histograms and scatterplots, and have easy import/export of data.

The generator COM object of DistributionView, the LOR.Distribution, can also be executed in any environment that allows creation of COM objects. Click here to get a sample Excel file running the generator. See the code in the end of this file with the Excel example, and also an example for use in MatLab.

The most recent version of this page is located at http://jcoelho.m6.net/freeware/DistributionView.html, and the instalation file can be downloaded at http://jcoelho.m6.net/freeware/DistributionView.msi (Version 2.3, 2004/07/10, 4.27Mb). An engine (command line program), that work with EngineTester (http://www.univ-ab.pt/~jcoelho/EngineTester.html), can be downloaded at http://jcoelho.m6.net/freeware/DistributionEngine.zip. This software is freeware, you can use it for any propose, if this page is refered. Contact email: jcoelho@univ-ab.pt.

Old versions: http://jcoelho.m6.net/freeware/DistributionView_2_21.msi (Version 2.21, 2005/03/02, 1.09Mb)

# Distribution List

## Continuous Distributions

 Distribution Arguments Comments Uniform min; max returns a value between min and max, with equal probability Exponential mean returns a value of a exponential distribution. If a set of values was generated by a uniform distribution, the difference between consecutive values, follow an exponential distribution. Normal mean; dev. returns a value of a normal distribution. These distributions are very common because a sum of several independent random variables of any distribution, is a normal distribution. Lognormal mean; mode; min returns a value of a lognormal distribution. These distributions are common because a product of several independent random variables of any distribution, is a lognormal distribution. Triangular min; mode; max returns a value of a triangular distribution. Is a distribution with a simple density function (a triangle), easy to explain in a non-statistic environment. Chi_square degree returns a value of a sum of "degree" N(0;1)^2 distributions t_student degree returns a value of N(0;1)/sqrt(CHI2(degree)/degree) F_distribution d1; d2 returns a value of (CHI2(d1)/d1)/(CHI2(d2)/d2) Cauchy location; scale returns a value of a Cauchy distribution. Fisher_Tippett (extreme value) a; b returns a value of a Fisher-Tippett distribution Laplace (double exponential) a returns a value of E(a)-E(a) Logistic location; scale returns a value of a Logistic distribution Pareto a; b returns a value of a Pareto distribution Weibull a; b returns a value of a Weibull distribution

## Discrete Distributions

 Distribution Arguments Comments Binomial N; p returns the number of success in N experiences with p probability of success Geometric p returns the number of failures until the first success are archived in  experiences with p probability of success Negative_Binomial r; p returns the number of failures until r success are archived in  experiences with p probability of success Hipergeometric Mp; Mq; N returns the number good elements in a random size N sample of a set with Mp good elements and Mq bad elements Poisson mean returns the number of events per time unit RND (random) x1;x2;...;xn returns one of x1;...;xn

# Function List

 Function Arguments Comments max x1;x2;...;xn returns the maximal value of x1;...;xn min x1;x2;...;xn returns the minimal value of x1;...;xn sum x1;x2;...;xn returns the sum of x1;...;xn mul x1;x2;...;xn returns the product of x1;...;xn div x1;x2 returns x1/x2 pow x1;x2 returns x1^x2 if x1;x2;x3 returns x2 if x1>0, otherwise returns x3 cond u;p1;d1;...;pn;dn The first distribution (u) is executed, and also the distributions p (p1,...,pn), subtracting the value returned by u. When this value is negative, in p3 for instance, d3 is returned. If u=[Uniform 0 1], then pi is the probability of di to be returned. set v1;d1;...;vn;dn Allows assigning distributions (d1) to variables (v1), and returns the last distribution (dn). Note that d2 can use v1, and d3 can use v1 and v2, and so on, allowing generation of dependent random variables. sin; sinh; asin x returns the sines, hyperbolic sines and arcsine (angles in radians). cos; cosh; acos x returns the cosines, hyperbolic cosines and arccosine. tan; tanh; atan x returns the tangent, hyperbolic tangent and arctangent. ceil, abs x returns the smallest integer that is greater than or equal to x and the absolute value of x exp; log; log10 x returns the exponential value, natural logarithm and base 10 logarithm sqrt x returns the square root lt x1; x2 returns x1x2 elt x1; x2 returns x1<=x2 egt x1; x2 returns x1>=x2 eq x1;...;xn returnsx1=...=xn or x1;...;xn returns x1||...||xn and x1;...;xn returns x1&&...&&xn not x returns !x + * / ^ <= >= < > = || && - are binary operators to SUM; MUL; DIV; POW; ELT; EGT; LT; GT; EQ; OR; AND. Example: "a*b" will expand to "[mul a b]"

# Constant List

 Constant Value Comments PI 3.14159265 the ratio of the circumference of a circle to its diameter EULER 2.718281828 The base of the natural logarithm

# Examples

 List sintax Function sintax Comments [Normal 0 1] Normal(0;1) Normal distribution, with mean 0 and standard deviation 1 [Exponential 10] Exponential(10) Exponential distribution, with mean 10 [rnd 1 2 3 4 5 6] rnd(1 2 3 4 5 6) Generation of 1 value between 6 [sum [rnd 1 2 3 4 5 6] [rnd 1 2 3 4 5 6]] rnd(1 2 3 4 5 6)+rnd(1 2 3 4 5 6) Generation of a sum of two values from 1 to 6 [set DADOS [sum [rnd 1 2 3 4 5 6] [rnd 1 2 3 4 5 6]] [or [eq DADOS 7] [eq DADOS 11]]] set(DADOS sum(rnd(1 2 3 4 5 6) rnd(1 2 3 4 5 6)) or(DADOS=7 DADOS=11) Generation of two value from 1 to 6, and two variables where one is the sum of the two values and other is 1 if the sum is 7 or 11, and 0 otherwise. [set Normal [Normal 0 1] Triangular [Triangular -1 0 1] Uniform [Uniform -1 1]] set(Normal Normal(0 1) Triangular Triangular(-1 0 1) Uniform Uniform(-1 1)) Three variables/distribuitions, a Normal, a Triangular and an Uniform distribution [cond [Uniform 0 100] 10 0 15 1 5 2 30 3 20 4 20 5] cond(Uniform(0 100) 10 0 15 1 5 2 30 3 20 4 20 5) A conditional distribution, generating discrete values: 0 (with 10%); 1 (15%); 2 (5%); 3 (30%); 4 (20%) 5 (20%) [set exp [Exponential 10] max [max [Exponential 10] [Exponential 10]]] set(exp Exponential(10) max max(Exponential(10) Exponential(10))) A exponential distribution with mean 10, and the max of two exponential distributions of mean 10 [sum [Exponential 10] [div [mul [Normal 0 1] [Normal 0 1]] [Uniform 1 2]]] Exponential(10)+Normal(0 1)*Normal(0 1)/Uniform(1 2) Expression envolving different distributions [set pow [pow [Normal 0 1] 2] mul [mul [Normal 0 1] [Normal 0 1]]] set(pow Normal(0 1)^2 mul Normal(0 1)*Normal(0 1)) The square of normal distribution, and the product of two normal distributions [cond [Uniform 0 100] 40 [Normal 10 1] 60 [Normal 15 2]] cond(Uniform(0 100) 40 Normal(10 1) 60 Normal(15 2)) Returns Normal(10 1) with 40% chance, and Normal(15 2) with 60% chance [set DA [Normal 10 1] [max [sum [Normal 10 1] DA] [sum [Normal 10 1] [max DA [Normal 10 1]]]]] set(DA Normal(10 1) max(Normal(10 1)+DA Normal(10 1)+max(DA Normal(10 1)))) Generation of a variable Normal(10 1) and other variable with some dependencies [set V1 [pow [Normal 0 1] 3] V2 [sum -10 [Exponential 10]]] set(V1 Normal(0 1)^3 V2 -10+Exponential(10)) Generation of two variables not independent

# VB Code to run LOR.Distribution

This code runs in VBA, and only needs the LOR.DLL file registered in the system, that is done by installing the DistributionView:

Dim dist As Object
Set dist = CreateObject("LOR.Distribution")
dist.seed = 1 ' set seed number
dist.Definition = "Normal(0;1)"
For Each x In Selection
dist.NextValue
x.Value = dist.Value
Next

# MatLAb Code to run LOR.Distribution

This code runs in a distribution.m file, and only needs the LOR.DLL file registered in the system, that is done by installing the DistributionView:

```function dist = distribution(definition)
% This function returns a function that use a COM object (LOR.Distribution)
% to generate distributions acoording to definition
% (see http://jcoelho.m6.net/freeware/DistributionView.html)

hCom=actxserver('LOR.Distribution');

hCom.Definition=definition;

dist=@f;

function v=f(x)
if nargin==1, hCom.Seed=x; end
hCom.NextValue();
v=hCom.Value;
end
end
```

This function returns a generator for the definition given. For instance, you can do things like:

c=distribution('Exponential(10)');
d=distribution('Max(Exponential(10);Normal(10;1))');
c() % returns a value that follows the distribution c
c(1); d(1); % resets seed number generator to 1, to allow re-generate the same values later
for k=1:100; p(k)=c(); end; % put 100 values in p, following the distribution c
for k=1:100; q(k)=d(); end; % put 100 values in q, following the distribution d

# R Code to run LOR.Distribution

To install R go to http://www.r-project.org/. The following code require that you install the library RDCOMClient for R, available in http://www.omegahat.org/RDCOMClient/.

```library(RDCOMClient)
dist=COMCreate("LOR.Distribution")
dist[["Definition"]]="Normal(0;1)"
dist[["Seed"]]=1
Generate<-function() {
dist\$NextValue()
dist\$Value()
}
```

The function Generate will return values acording to the distribution.

Last change on 2006-04-04