AN ALGORITHM FOR GENERATING RANDOM NUMBERS WITH BINOMIAL DISTRIBUTION. Dorin BOCU 1. PRELIMINARIES

Similar documents
A GENERALIZATION OF A CLASSICAL MONTE CARLO ALGORITHM TO ESTIMATE π

On asymptotic behavior of a finite Markov chain

MIHAIL MEGAN and LARISA BIRIŞ

CONVERGENCE OF THE FRACTIONAL PARTS OF THE RANDOM VARIABLES TO THE TRUNCATED EXPONENTIAL DISTRIBUTION

MARKING A BINARY TREE PROBABILISTIC ANALYSIS OF A RANDOMIZED ALGORITHM

ON THE MOMENTS OF ITERATED TAIL

Bulletin of the Transilvania University of Braşov Vol 9(58), No Series III: Mathematics, Informatics, Physics, 67-82

Political Science Math Camp: Problem Set 2

Journal of Engineering Studies and Research Volume 19 (2013) No. 1 29

Using the Autoregressive Model for the Economic Forecast during the Period

An Analysis of Top Trading Cycles in Two-Sided Matching Markets

Sample Spaces, Random Variables

The algorithm of adaptive random search for discrete-continuous optimization 1

Lecture 1: Brief Review on Stochastic Processes

Random variables. DS GA 1002 Probability and Statistics for Data Science.

THE FUNDAMENTAL PHENOMENOLOGICAL INFORMATION OF THE UNIVERSE

Research Article On Maslanka s Representation for the Riemann Zeta Function

Fixed point theorems for Ćirić type generalized contractions defined on cyclic representations

STUDY OF EFFECTS OF VIBRATIONS CAUSED BY RAILWAY TRAFFIC TO BUILDINGS

FUNCTIONS OF ONE RANDOM VARIABLE

On the law of large numbers for free identically distributed random variables 1

Some Remarks about Mastrogiacomo Cohomolgy

The 5rd International Conference on. COMEC OCTOBER 2013, Brasov, Romania

EXPERIMENTAL RESEARCH REGARDING THE HD RADIAL BEARINGS IN THE CASE OF STATIC CHALLENGING WORKING

THE CALCULUS OF A NEW MUSICAL SCALE FREQUENCIES

Northwestern University Department of Electrical Engineering and Computer Science

Induction Heating Spiral Inductor Comparison between Practical Construction and Numerical Modeling

A Probability Primer. A random walk down a probabilistic path leading to some stochastic thoughts on chance events and uncertain outcomes.

The Wright-Fisher Model and Genetic Drift

A best approximation property of the generalized spline functions

SOME APPLICATIONS OF THE HILBERT TRANSFORM

On the Distribution of Perfect Powers

The equivalence between a standard H-cone of functions on a saturated set and Exc U

Probability and Statistics

CHAPTER 5. Interactive Turing Machines

ANALYSIS OF THE RADIAL MAGNETIC FIELD IN AN ELECTRIC MACHINE SLOT

Stochastic Simulation

A = A U. U [n] P(A U ). n 1. 2 k(n k). k. k=1

3.2 Configuration model

Let (Ω, F) be a measureable space. A filtration in discrete time is a sequence of. F s F t

G.PULLAIAH COLLEGE OF ENGINEERING & TECHNOLOGY DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING PROBABILITY THEORY & STOCHASTIC PROCESSES

Annals of West University of Timisoara

Chapter 4. Continuous Random Variables

11. Statistical Evidence of Theomatics demonstrated at Luke 15:10-32

2.1 Elementary probability; random sampling

MATH 310 Course Objectives

Randomness and Computation

Performance Evaluation and Comparison

UNIQUENESS ALGEBRAIC CONDITIONS IN THE STUDY OF SECOND ORDER DIFFERENTIAL SYSTEMS. Let us consider the following second order differential system:

On Approximating a Generalized Binomial by Binomial and Poisson Distributions

SHORTEST PATH PROBLEM BY MINIMAL SPANNING TREE ALGORITHM USING BIPOLAR NEUTROSOPHIC NUMBERS

Math 180A. Lecture 16 Friday May 7 th. Expectation. Recall the three main probability density functions so far (1) Uniform (2) Exponential.

Stochastic Simulation

On the Weight Distribution of N-th Root Codes

Renewal theory and its applications

A theoretical comparison between batwing and lambertian distributions of power LEDs related to an interior lighting system

Probability, Random Processes and Inference

Induction. Induction. Induction. Induction. Induction. Induction 2/22/2018

Eötvös Loránd University, Budapest. 13 May 2005

On a theorem of Ziv Ran

ECE 313 Probability with Engineering Applications Fall 2000

Optimum Repartition of Transport Capacities in the Logistic System using Dynamic Programming

Counting. Math 301. November 24, Dr. Nahid Sultana

U.P.B. Sci. Bull., Series A, Vol. 74, Iss. 3, 2012 ISSN SCALAR OPERATORS. Mariana ZAMFIR 1, Ioan BACALU 2

Chapter 6 - Random Processes

Introduction to Probability

Water Hammer Simulation For Practical Approach

Communication Theory II

Random Process Lecture 1. Fundamentals of Probability

1. For each statement, either state that it is True or else Give a Counterexample: (a) If a < b and c < d then a c < b d.

Chapter 1. Sets and probability. 1.3 Probability space

Elimination of Arbitrage States in Asymmetric Information Models

Note About a Combinatorial Sum

POLAR CHARACTERISTIC OF ENERGETIC INTENSITY EMITTED BY AN ANISOTROPIC THERMAL SOURCE IRREGULARLY SHAPED

in the company. Hence, we need to collect a sample which is representative of the entire population. In order for the sample to faithfully represent t

EECS 495: Randomized Algorithms Lecture 14 Random Walks. j p ij = 1. Pr[X t+1 = j X 0 = i 0,..., X t 1 = i t 1, X t = i] = Pr[X t+

EXISTENCE OF STRONG SOLUTIONS OF FULLY NONLINEAR ELLIPTIC EQUATIONS

Machine Learning Methods and Real-Time Economics

CSE548, AMS542: Analysis of Algorithms, Spring 2014 Date: May 12. Final In-Class Exam. ( 2:35 PM 3:50 PM : 75 Minutes )

THE USE OF TIN SOFTWARE IN STATISTICAL HYPOTHESIS TESTING. CASE STUDY

Interlude: Practice Final

UNBOUNDED OPERATORS ON HILBERT SPACES. Let X and Y be normed linear spaces, and suppose A : X Y is a linear map.

2905 Queueing Theory and Simulation PART IV: SIMULATION

Chapter 6. Hypothesis Tests Lecture 20: UMP tests and Neyman-Pearson lemma

Introduction and Preliminaries

04. Random Variables: Concepts

Exponential Distribution and Poisson Process

Random Variable. Pr(X = a) = Pr(s)

Math 259: Introduction to Analytic Number Theory Functions of finite order: product formula and logarithmic derivative

LINEAR ALGEBRA W W L CHEN

SUMS PROBLEM COMPETITION, 2000

µ X (A) = P ( X 1 (A) )

Principles of Program Analysis: A Sampler of Approaches

Discrete Finite Probability Probability 1

Mechanical Behavior Analysis with the Finite Elements Method of Solar Collector s Tracking Systems

ON LINEAR RECURRENCES WITH POSITIVE VARIABLE COEFFICIENTS IN BANACH SPACES

Q-Learning for Markov Decision Processes*

Introduction to Mobile Robotics Probabilistic Robotics

MATHEMATICS. The assessment objectives of the Compulsory Part are to test the candidates :

A DUALITY APPROXIMATION OF SOME NONLINEAR PDE s

Transcription:

Yugoslav Journal of Operations Research 10 (2000), Number 1, 99-108 1 AN ALGORITHM FOR GENERATING RANDOM NUMBERS WITH BINOMIAL DISTRIBUTION Dorin BOCU Faculty of Science, Department of Computer Science "Transilvania" University of Braşov, Romania Abstract: In this paper we introduce an algorithm for generating random numbers with binomial distribution. The algorithm is based on the idea of a "pipe" between the simulation of a statistical experiment and the algorithm for selection according to utility, often invoked in genetic search problems. Keywords: Binomial distribution, selection according to utility. 1. PRELIMINARIES First, we shall introduce several definitions and results that are useful in the main statements of the paper. Definition 1.1. We call a system a set of interacting components that operate within a boundary to a certain predefined purpose. The boundary filters the types and flow rates of inputs and outputs between the system and its environment. The specification of the boundary defines both the system and the environment of the system. We denote with S an object, process or phenomenon indicated according to Definition 1.1. Definition 1.2. We call the context of a system the set of restrictions under which the system can achieve its purpose. Eliminating or adding restrictions to the context of a system S affects its knowing, so it requires a new specification effort. We denote with C S the context of system S.

100 D. Bocu / An Algorithm for Generating Random Numbers with Binomial Distribution Definition 1.3. We call the observation criterion of a system S by an instance I the set of all different and significant states of system S from the point of view of instance I. We denote with O the observation criterion of system S by instance I. We remark that SI O SI is a representing model of system S in context C S instance I., according to the perception of Definition 1.4. We call an experiment the repeated analysis of a system S working in the same context C S and according to the same observation criterion O SI. We denote with E a generic experiment. Definition 1.5. We call an elementary random event the result of an unpredictable experiment. If S is a system which is the object of an experiment E, we call the result of the experiment the state in which system S arrives at the end of experiment E. The set of distinct events, characteristic of an unpredictable experiment, is called a complete event system. We denote with E the complete event system associated to experiment E. Definition 1.6. We call a random event any proper subset of E. We denote random events by A, B, C,... Definition 1.7. Let E be experiment whose complete system event is E. If ( ) p : P( E) [ 0, so that p is a measure of the posibility of the occurence of events A E then we say that p is a probability. Definition 1.8. Let E be experiment whose complete event system is E. We call the distribution law of the events related to E a mathematical model by means of which we can make probabilistic predictions about the results of experiment E. Such mathematical models are: probability density, repartition function, characteristic function the random variable. Out of the usual distribution laws we illustrate: uniform distribution, binomial distribution, Poisson distribution, etc. This paper does not aim to discuss aspects related to the theoretical contents of any of these laws. However, we shall study to obtain an algorithm which allows the simulation of the behaviour of a system with a binomial distribution of events. Related to the binomial experiment we present the definition below. Definition 1.9. We say that a random variable X given by table: 0 X : p 0 1 p 1 2 p 2!! n p n has a binomial distribution with parameters n and p if:

D. Bocu / An Algorithm for Generating Random Numbers with Binomial Distribution 101 i i n i i n, p = P( X = i) = C p ( 1 p) ; i = 0 n Remark 1.1. The most simple way to introduce a binomial distribution is by studying the following experiment: "Let E be an experiment related to which event A occurs with probability p and event A occurs with probability 1 p. Given the experiment E 1 which is obtained by repeating experiment E n-times we raise the question: what is the probability that A occurs i-times?". The theoretical probability that the above-mentioned event occurs is specified in Definition 1.9. In this paper we are looking for an algorithm which generates integer numbers belonging to { 0, 1, according to the law of binomial distribution of n and p given parameters. Proposition 1.1. A random variable Y which takes values uniformly distributed in [ 0, has the repartition function: F Y 0; if x (, 0] ( x) = x; if x [ 1, ) Proof: Because Y has the uniform distribution of values in [ 0, then the probability density is: f Y 1; if x [ 0, ( x) = 0; if x R \[ 0, So: F Y x ( x) = f 0; if x (, 0] ( x) dx = x; if x ( 0, 1; if ( 1, ) Y 0 x Proposition 1.2. Let k ( 0, 1) and experiment E be defined in this way: 1) A random number NRA ( 0, 1) is generated according to the uniform distribution law; 2) If NRA k then we consider that event A is realized; 3) If NRA > k then we consider that event A is not realized; What is the probability of event A? Proof: P( A) = P( NRA k) = P( 0 NRA k) = P( NRA = 0) + P( 0 < NRA k). have Because NRA is uniformly distributed in [ 0,, according to Definition 1.1 we P( A) = F ( k) F ( 0 ) k. NRA NRA =

102 D. Bocu / An Algorithm for Generating Random Numbers with Binomial Distribution The statement of Proposition 1.2 represents the basis of a procedure which models an abstract experiment E related to which an event A occurs with probability k. So, the experiment E which represents the basis of introducing binomial distribution as a consequence of E repeated n-times. Proposition 1.3. Let RND be a function which returns randomly and uniformly distributed numbers in [ 0, and let S be a system having the space of states Ω = { 0, 1,. Let F = { f 0, f 1, f be the utility vector related to the states of system S so that f i [ 0, i { 0, 1, and n i i= 0 f = 1. Then the algorithm: NRA = RND IndSel = min { f f + + f < NRA f + f +! + f } 0 i n 0 + 1! i 1 0 1 is a selection algorithm according to the utility of the states of system S. Proof: Because RND returns randomly, uniformly distributed numbers in [ 0,, according to Proposition 1.1 we have: F RND So, we have: 0; if x (, 0] ( x) = x; if x ( 0, 1; if x ( 1, ) P IndSel = i) = P( f + f + + f < NRA f + f +! + f ) ( 0 1! i 1 0 1 i F RND ( f0 + f1 +! + fi ) FRND ( f0 + f1 +! + fi 1 = fi. = ) The demonstration is concluded. i 2. ALGORITHM GBDRN GBDRN is the abbreviation for Generating Binomially Distributed Random Numbers. Theorem 2.1. The algorithm GBDRN specified by: PrelParDB(n, p) ZeroCom(VUABS)

D. Bocu / An Algorithm for Generating Random Numbers with Binomial Distribution 103 PrelAmplExp(nre) for i := 1 to nre do ConApA:= 0 for j := 1 to n do NrA := RND if NrA p then ConApA := ConApA +1 end VUABS[ConApA] := VUABS[ConApA] +1 end VUREL := Convert(VUABS) NAL := RNDBD It generates randomly, binomially distributed numbers in { 0, 1,. In the above algorithm: -PrelParDB(n, p) is a procedure which takes over the parameters of binomial distribution which represent the basis of generating random numbers. -ZeroCom(VUABS) is a procedure which sets at zero the components of absolute utility vector VUABS. -PrelAmplExp is a procedure which takes over the size of the generating experiment. -ConApA is a variable which counts the number of occurences of the hypothetical event A having probability p. -Convert is a function which transforms absolute utility vector VUABS to relative utility vector VUREL. -RNDBD is the function which returns a number in { 0, 1, that is randomly, binomially distributed by parameters n and p. The selection of the returned number is made according to the utilities associated to them in VUREL. * N Proof: Let n and p ( 0, 1) be the number taken over by procedure PrelParDB. Let nre be a number high enough taken over by procedure PrelAmplExp. According to Proposition 1.2 the sequence NrA := RND if NrA p then ConApA := ConApA +1 simulates experiment E.

104 D. Bocu / An Algorithm for Generating Random Numbers with Binomial Distribution The sequence for j := 1 to n do NrA := RND if NrA p then ConApA := ConApA +1 end simulates experiment E 1 indicated in Definition 1.9. After repeating experiment E 1 many times, absolute utility vector VUABS will contain the frequency with which A occures i-times in experiment E 1 for i { 0, 1,. Applying Proposition 1.3 the result is that the random numbers are generated according to a binomial distribution. 3. BORLAND PASCAL IMPLEMENTATION OF GBDRN unit RNDBD; {$IFNDEF CPU87} {$N+} {$ENDIF} {The unit contains the capabilities necessary to } {generate random numbers with a binomial distribution } {by parameters <n> and <p> given. } interface uses crt,dos,objects; type {Object type which incapsulates the capabilities of } {generating random numbers with a binomial } {distribution. } PTO_RNDBD = ^TO_RNDBD; TO_RNDBD = object N :longint; P :double; NRE: :longint; Total :double;

D. Bocu / An Algorithm for Generating Random Numbers with Binomial Distribution 105 PColUAbs : PCollection; constructor Init (FN:longint ;FP:double ;FNRE:longint); destructor Done;virtual; procedure GenExpBinom; function RNDBD:longint; implementation type {Object type which specifies a generic element } {of the collection in which absolute utility is } {kept. } PTElCol = ^TElCol; TElCol = object (Tobject) UAbs:longint; constructor init(u:longint); destructor done;virtual; {Constructor TElCol... } constructor TElCol.Init(U:longint); UAbs:=U; {Destructor TElCol... } destructor TElCol.Done; {Constructor TO_RNDBD... } constructor TO_RNDBD. Init (FN: longint ; FP: double; FNRE: longint); if (FP>=0) and (FP<=1) then N:=FN; P:=FP; NRE:=FNRE; PColUAbs:=new (PCollection, init{fn+1, 10));

106 D. Bocu / An Algorithm for Generating Random Numbers with Binomial Distribution GenExpBinom; end else gotoxy(1, 24); clreol; textcolor(red); textbackground(white+blink); write('the parameter <p> is not in [0,!!!'); readkey; halt; {Destructor TO_RNDBD... } destructor TO_RNDBD. Done; dispose (PColUAbs, Done); {Procedure simulates a binomial experiment by } {parameters <n> and <p> given. } procedure TO_RNDBD.GenExpBinom; var I, J :longint; ConApA :longint; NRA: double; MAN: longint; PElCol : PTElCol; for I:=0 to N do PColUAbs^.Insert (new(ptelcol,init (0))); randomize; for I:=1 to NRE do ConApA:=0; for J:=1 to N do NRA: =random; if NRA<=P then inc(conapa);

D. Bocu / An Algorithm for Generating Random Numbers with Binomial Distribution 107 PElCol:=PColUAbs^.AT(ConApA); MAN:=PElCol^.UAbs; inc(man); PElCol^.UAbs:=MAN; PColUAbs^.AtPut(ConApA,PEICol); Total:=0; for I:=0 to N do PElCol:=PColUAbs^.At(I); Total:=Total+PElCol^.UAbs; {Function returns the numbers which can take values } {from <0> to <n>, binomially distributed. } function TO_RNDBD.RNDBD: longint; var I: integer; Termen: double; GenAl, Suma: double; PElCol : PTElCoI; GenAl:=random; I:= 1 Suma:=0; repeat inc(i); PElCol:=PColUAbs^.At (I); Termen:=PElCol^.UAbs; Suma:=Suma+(Termen/Total); until Suma>=GenAl; RNDBD:=I; end.

108 D. Bocu / An Algorithm for Generating Random Numbers with Binomial Distribution 4. CONCLUSIONS The prsesent algorithm can be used from any Pascal program which imports unit RNDBD. The relation between the theoretical probability of binomial repartition by n, p parameters and the frequency with which random numbers are generated by the capabilities of the RNDBD unit will be analyzed in a future paper. REFERENCES [ Bocu, D., "On the short-term behaviour of genetic algorithms Yugoslav Journal of Operations Research, 7 (1997) 55-63. [2] Bocu, D., "Modelarea matematica a sistemelor cu comportament stochastic Ph.D. dissertation, Universitatea "Transilvania" Brasov, 1996 (In Romanian). [3] Onicescu, O., Probabilitati şi procese aleatoare, Editura Ştiintifica şi Enciclopedica, 1977. [4] Sacuiu, I., and Zorilescu, D., Numere aleatoare-aplicatii in economie, industrie şi studiul fenomenelor naturale, Editura Academiei,1978.