Chapter 3 Stochastic Random Models - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Chapter 3 Stochastic Random Models

Description:

Keep trying until success, then passivate. statistics. trial. try. active. passive. if (r. ... passivate() receptive ... If store has reached zero, passivate. ... – PowerPoint PPT presentation

Number of Views:71
Avg rating:3.0/5.0
Slides: 13
Provided by: bernardp
Category:

less

Transcript and Presenter's Notes

Title: Chapter 3 Stochastic Random Models


1
Chapter 3 Stochastic (Random) Models
  • Probability Distributions
  • Generating Random Events
  • Generating Random Numbers
  • Testing Random Distributions
  • Gathering Statistics
  • Comparing Random Search Methods

2
Recognizing Common Probability Distributions
Distributions such as the Normal (bell shaped
curve) and exponential have well defined means
and standard deviations
Normal (Gaussian)
statistics rand
Exponential
Uniform
3
Generating Random Events From a Uniform
Distribution
Sample from a uniform distribution with range 0
to 1. Send each sample as input to a function
with domain 0.1 and output a set of
events. Then the space occupied by an event on
in the unit interval becomes its probability.
Function with domain 0,1
uniformly distributed numbers from 0 to 1
events with known probability
probability of getting red is 0.3 that of
getting green is 0.7
1
0
probability of getting red is 0.5 so is that of
getting green.
How do we find the right interval sizes for a
given probability assignment? We divide the unit
interval by creating break points by summing the
probabilities. For example, given P(red) .2,
P(yellow) .3 and P(red) .5, breakpoint 1
.2 breakpoint 2 .2.3 .5 breakpoint 3 .5
.5 1.
For three events we divide the interval into 3
parts
4
Generating Random Numbers Example pulseGenrRand
public class rand extends entity Random
ran public rand(long seed) super() ran
new Random((long)seed) public double
uniform(double lo ,double hi) return
ran.nextDouble() (hi - lo) lo public
double uniform(double hi) return
uniform(0,hi) public double expon(double
mean) return -meanMath.log(uniform(0,1)) pu
blic double normal1() double u
uniform(0,1) return Math.sqrt(-2Math.log(u))M
ath.cos(2Math.PIu)
public class pulseGenrRand extends
pulseGenr protected rand r protected long
seed public void initialize() r new
rand(seed) holdIn("active",r.uniform(interArrival
Time)) super.initialize() public void
deltext(double e,message x) Continue(e) if
(phaseIs("passive")
somethingOnPort(x,"start")) //
holdIn("active",r.uniform(interArrivalTime))
holdIn("active",r.expon(interArrivalTime))

statistics rand
statistics pulseGenrRand
public double pareto( double location, double
shape ) double u uniform(0,1) return
location Math.pow( u, (-1/shape) ) public
double lognormal( double mean, double sig
) return Math.pow( 10, normal( mean, sig ) )
public double normal(double mean,double sig)
return mean signormal1() public double
posNormal(double mean,double sig) double save
normal(mean,sig) return save
gt0?saveposNormal(mean,sig)
5
Generating Random Events -- Example Random Trials
try
active
receptive
passive
if (r.uniform(1) lt probOfSuccess) success
true
if (success) passivate()
if (success) outVal(1)
success
public void initialize() super.initialize() r
new rand(id) success false passivateIn("recept
ive") public void deltext(double e,message
x) Continue(e) if (phaseIs("passive")
somethingOnPort(x,"try")) holdIn("active",1)
public void deltint() if (success)passivate()
else if (r.uniform(1)lt probOfSuccess) success
true holdIn("active",1)
pseudo random number generator, rand generates a
unique stream of outputs for a given initial seed
(here specified by id)
statistics trial
Upon command try hold for 1 unit of time and
output a 1 with a given probability of success.
Keep trying until success, then passivate
statistics rand
6
Specializing rand and pulseGenr to provide easy
and consistent plug-ins for interpulse time and
size distributions
sample() is polymorphically over-riden by
subclass methods to provide the appropriate
samples
rand
public pulseGenrRandInterval extends pulseGenr
protected rand r, rinit public
pulseGenrRandInterval( String nm,double
interPulseTime) this(nm,interPulseTime,1,new
randUniform(1)) //rinit is assigned randUniform
instance public void initialize() r rinit
holdIn("active",r.sample())
super.initialize()
sample()
statistics pulseGenrRandInterval
rand Normal
rand Expon
rand Uniform
rand
statistics randUniform
statistics rand
public class randUniform extends rand protected
double lo, hi public randUniform(l ong
seed,double lo ,double hi) super(seed)
this.lo lo this.hi hi public double
sample() return uniform(lo,hi)
public class pulseGenrRandSize extends
pulseGenr public pulseGenrRandSize( String
nm,double mean,double sig) this(nm,mean,sig,new
randUniform(1)) public void deltint() size
r.sample() holdIn("active",10)
statistics pulseGenrRandIntSize
7
Exercise Extend Class trial so that the
probability of success decreases as the number of
successes increases
trial
trialWDiminReturns
Add an integer variable called store to class
trial Let the probOfSuccess depend on the
current size of store, e.g., probOfSuccess
store/100 When receive something on port
try If sample is successful, subtract 1 from
store (and readjust probOfSuccess) If store has
reached zero, passivate. Otherwise, return to
phase receptive to allow next trial.
statistics trialWDiminReturns
8
Testing Randomly Generated Distributions
statistics randDistaTest
In randDistTest, we can test distributions
generated by pulseGenrRandInterval. We can
run, in parallel, a desired number of replicates,
i.e., the same distribution with different
initial seeds. Here, we show the results of
running two replicates of the uniform
distribution. A initial seed always yields the
same stream, but different seeds specify
different streams. In this case, two different
seeds results in statistics that are close to
those expected from a uniform distribution(0,1).
To get closer agreement we need to run more
replicates and/or each one for longer. The
deviation decreases as the standard deviation
divided by sqare root of the number fo trials.
9
Gathering statistics Example distribGenr
public class statistics public statistics
(double numbers)... public int
size()... public void add(double n)... public
void toArray() public String toString(double
array)... public double average()... public
double variance()... public double
std()... public double partition ( double
begin, double end, int numClasses
) public String distribution()
statistics statistics
statistics distribGenr
statistics statCollector
In distribGenr, pulseGenrRand generates pulses
which are counted by the sum, sf, until genr
signals that a given time interval has elapsed.
The count at that point is entered as a sample
into statCollector,stat. The timer lets this
cycle repeat to obtain a given number of
samples. The data are analyzed for mean,
standard deviation, and probability
distribution. The distribution shown at left
agrees with the prediction that an exponential
interarrival time of 10 (in genrRand) will yield
a Poisson distribution with mean number events of
10 and standard deviation, 101/2 3.16 in an
interval of 100 .
public statCollector() statitstics stat new
statistics() public void deltext(double
e,message x) Continue(e) for (int i0 ilt
x.getLength()i) if (messageOnPort(x,"in",i))
doubleEnt dent (doubleEnt)x.getValOnPort("in",i
) stat.add(dent.getv())
holdIn("sendOut",0)
10
  • Thus there are types of searches
  • simultaneous keep trying until all components
    are successful
  • sequential try each one in sequence
  • cumulative try in parallel, preserving
    successful ones until all are successful
  • Which takes the longest? the shortest? time to
    adapt all components.

Trial and Error Search
A system whose components have to be optimized by
trial and error is modeled by a oneDimCellSpce
whose cells are random trial atomic models.
If all components interact then it may be that
they all have to be adjusted at once. If they
are completely independent, then it is possible
to separately optimize them. A case between
these extremes is where there is a sequence such
that later adjustments will not affect earlier
ones.
cumulative send try to each cell ends with the
cell that has taken the longest time to adapt
oneDimCellSpace
try
trial
trial
thrsholdReset
sum
reset
oneDimCellSpace searchCellSpace
simultaneous send try to each cell reset sum
and cells each step repeat trial every step
until all successful
sequential send try to first cell only
success of a cell triggers next trial
11
Trial and Error Search (contd)
  • We study the types of searches with
    searchCellSpace with different coupling rules as
    shown.
  • In searchOpt, for a given search type and a
    fixed number of components, N, we can run
    replicates with different initial seeds and
    collect their completion time statistics.
  • With ProbOfSuccess .5, we get the following

oneDimCellSpace searchCellSpace
sequential avg time increases by constant for
each additional component
if (searchType.startsWith("simultaneous"))
coupleOneToAll(threshNot,"out","reset")
coupleOneToAll(sf,"out","try") else
if (searchType.startsWith("sequential"))
doNeighborCoupling(1,"outVal","try")
addCoupling(sf,"out",withName("cell_0"),"try"
) else coupleOneToAll(sf,"out","try
")
slope 4.2
limit 9
oneDimCellSpace searchOpt
cumulative by N 25 the avg time reaches a
limit
simultaneous exponential increase in average
time to completion
12
Trial and Error Search (contd) examining the
cumulative case
for pN much larger than 1 and much smaller than
1, approximations indicate cummulative approaches
completion exponentially for pN 1, we do
experimentation below
0 10 20 30 40
small p and large N lt 1/p imply large time
pN 1, for N 1,2,10,40
Write a Comment
User Comments (0)
About PowerShow.com