<< Chapter < Page | Chapter >> Page > |
Several other important properties of the quantile function may be established.
Suppose simple random variable X has distribution
Figure 1 shows a plot of the distribution function F X . It is reflected in the horizontal axis then rotated counterclockwise to give the graph of versus u .
We use the analytic characterization above in developing a number of m-functions and m-procedures.
m-procedures for a simple random variable
The basis for quantile function calculations for a simple random variable is the formula above. This is implemented in the m-function dquant , which is used as an element of several simulation procedures.To plot the quantile function, we use dquanplot which employs the stairs function and plots X vs the distribution function . The procedure dsample employs dquant to obtain a “sample” from a population with simple distribution and tocalculate relative frequencies of the various values.
X = [-2.3 -1.1 3.3 5.4 7.1 9.8];PX = 0.01*[18 15 23 19 13 12];dquanplot
Enter VALUES for X XEnter PROBABILITIES for X PX % See
[link] for plot of results
rand('seed',0) % Reset random number generator for referencedsample
Enter row matrix of values XEnter row matrix of probabilities PX
Sample size n 10000
Value Prob Rel freq
-2.3000 0.1800 0.1805-1.1000 0.1500 0.1466
3.3000 0.2300 0.23205.4000 0.1900 0.1875
7.1000 0.1300 0.13339.8000 0.1200 0.1201
Sample average ex = 3.325Population mean E[X] = 3.305Sample variance = 16.32
Population variance Var[X]= 16.33
Sometimes it is desirable to know how many trials are required to reach a certain value, or one of a set of values. A pair of m-procedures are available for simulation of that problem.The first is called targetset . It calls for the population distribution and then for the designation of a “target set” of possible values. The second procedure, targetrun , calls for the number of repetitions of the experiment, and asks for the number of members ofthe target set to be reached. After the runs are made, various statistics on the runs are calculated and displayed.
X = [-1.3 0.2 3.7 5.5 7.3]; % Population valuesPX = [0.2 0.1 0.3 0.3 0.1]; % Population probabilitiesE = [-1.3 3.7]; % Set of target statestargetset
Enter population VALUES XEnter population PROBABILITIES PX
The set of population values is-1.3000 0.2000 3.7000 5.5000 7.3000
Enter the set of target values ECall for targetrun
rand('seed',0) % Seed set for possible comparison
targetrunEnter the number of repetitions 1000
The target set is-1.3000 3.7000
Enter the number of target values to visit 2The average completion time is 6.32
The standard deviation is 4.089The minimum completion time is 2
The maximum completion time is 30To view a detailed count, call for D.
The first column shows the various completion times;the second column shows the numbers of trials yielding those times
% Figure 10.6.4 shows the fraction of runs requiring t steps or less
m-procedures for distribution functions
A procedure dfsetup utilizes the distribution function to set up an approximate simple distribution. The m-procedure quanplot is used to plot the quantile function. This procedure is essentially the same as dquanplot, exceptthe ordinary plot function is used in the continuous case whereas the plotting function stairs is used in the discrete case. The m-procedure qsample is used to obtain a sample from the population. Since there are so many possible values, these arenot displayed as in the discrete case.
F = '0.4*(t + 1).*(t<0) + (0.6 + 0.4*t).*(t>= 0)'; % String
dfsetupDistribution function F is entered as a string
variable, either defined previously or upon callEnter matrix [a b] of X-range endpoints [-1 1]Enter number of X approximation points 1000
Enter distribution function F as function of t FDistribution is in row matrices X and PX
quanplotEnter row matrix of values X
Enter row matrix of probabilities PXProbability increment h 0.01 % See
[link] for plot
qsampleEnter row matrix of X values X
Enter row matrix of X probabilities PXSample size n 1000
Sample average ex = -0.004146Approximate population mean E(X) = -0.0004002 % Theoretical = 0
Sample variance vx = 0.25Approximate population variance V(X) = 0.2664
m-procedures for density functions
An m- procedure acsetup is used to obtain the simple approximate distribution. This is essentially the same as the procedure tuappr, except thatthe density function is entered as a string variable. Then the procedures quanplot and qsample are used as in the case of distribution functions.
acsetup
Density f is entered as a string variable.either defined previously or upon call.
Enter matrix [a b]of x-range endpoints [0 3]
Enter number of x approximation points 1000Enter density as a function of t '(t.^2).*(t<1) + (1- t/3).*(1<=t)'
Distribution is in row matrices X and PXquanplot
Enter row matrix of values XEnter row matrix of probabilities PX
Probability increment h 0.01 % See
[link] for plot
rand('seed',0)qsample
Enter row matrix of values XEnter row matrix of probabilities PX
Sample size n 1000Sample average ex = 1.352
Approximate population mean E(X) = 1.361 % Theoretical = 49/36 = 1.3622Sample variance vx = 0.3242
Approximate population variance V(X) = 0.3474 % Theoretical = 0.3474
Notification Switch
Would you like to follow the 'Applied probability' conversation and receive update notifications?