0% found this document useful (0 votes)
2 views

probability

Ffggg

Uploaded by

neetsuccess001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

probability

Ffggg

Uploaded by

neetsuccess001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

4/27/2017

Overview
IMGD 2905
• Statistics important for • What are some examples of
game analysis probabilities needed for
• Probability important for game development?
Probability statistics
• So, understand some basic
probability
Chapters 4 & 5 • Also, probability useful for
game development

https://www.mathsisfun.com/data/i
mages/probability-line.svg

Overview Probability Introduction


• Statistics important for • Probability attack will • Probability – way of assigning • Roll die (d6) and get 6
game analysis succeed numbers to outcomes to express – elementary event
• Probability important for • Probability loot from enemy likelihood of event • Roll die (d6) and get even number
statistics contains rare item • Event – outcome of experiment – compound event, consists of
or observation elementary events 2, 4, and 6
• So, understand some basic • Probability enemy spawns – Elementary – simplest type for • Pick card from standard deck and
probability at particular time given experiment get queen of spades
– Joint/Compound – more than one
• Also, probability useful for • Probability action (e.g., elementary
– elementary event
game development building a castle) takes • Pick card from standard deck and
particular amount of time get face card
– compound event
• Probability players at server • Observe players logging into
MMO and see if time between
two arrivals is more than 15
seconds

https://cdn.kastatic.org/googleusercontent/Z0TuLq2KolavsrfDXSbLqi0S-
https://www.mathsisfun.com/data/i wnlCrC13cKGG68wK9ljrTiXzRqvfq7IpWNzcwgzlpEOI8YmMafp4K4zO0sanvXu
mages/probability-line.svg

Outline Probability – Definitions


• Exhaustive set of events • Roll D6: Events: 1, 2, 3, 4, 5, 6
• Introduction (done) – set of all possible – exhaustive, mutually exclusive
outcomes of
• Probability (next) experiment/observation
• Roll D6: Events: get even
number, get number divisible by
• Probability Distributions • Mutually exclusive sets
of events – elementary
3, get a 1 get a 5
– exhaustive, but overlap
events in each do not • Observe logins: time between
overlap arrivals <10 seconds, 10+ and
<15 seconds inclusive, or 15+
seconds
– exhaustive, mutually exclusive
• Observe logins: time between
arrivals <10 seconds, 10+ and
<15 seconds inclusive, or 10+
seconds
– exhaustive, but overlap

1
4/27/2017

Probability – Definition Assigning Probabilities


• Probability – likelihood of event to occur, measured by ratio
of favorable cases to unfavorable cases • Classical (by theory)
– In many cases, exhaustive, mutually exclusive outcomes equally
• Set of rules that probabilities must follow likely  assign each outcome probability of 1/n
– Probabilities must be between 0 and 1 (but often written/said – e.g., d6: 1/6, Coin: prob heads ½, tails ½, Cards: pick Ace 1/13
as percent)
– Probabilities of set of exhaustive, mutually exclusive events must • Empirically (by observation)
add up to 1 – Obtain data through measuring/observing
• e.g., D6: events 1, 2, 3, 4, 5, 6. Probability of 1/6th to each – e.g., Watch how often people play League of Legends in lab
versus some other game. Say, 30% LoL. Assign that as probability
 legal set of probabilities
• Subjective (by hunch)
• e.g., D6: events 1, 2, 3, 4, 5, 6. Probability of ½ to 1, ½ to 2,
and 0 to all the others – Based on expert opinion or other subjective method
 Also legal set of probabilities – e.g., e-sports writer says probability Team SoloMid (League team)
will win World Championship is 25%
– Not how honest d6’s behave in real life!

So, how to assign probabilities?

Rules About Probabilities (1 of 2) Rules About Probabilities (2 of 2)


• Complement: A an event, event “A does not • Independence: One occurs doesn’t affect probability that
other occurs
occur” called complement of A, denoted A’ – e.g., 2d6: A= die 1 get 5, B= die 2 gets 6. Independent, since
P(A’) = 1 - P(A) result of one roll doesn’t affect roll of other
– Probability both occur P(A and B) = P(A) x P(B)
– e.g., d6: P(6) = 1/6, complement is P(6’) and – e.g., 2d6: prob of “snake eyes” is P(1) x P(1) = 1/6 x 1/6 = 1/36
probability of not 6 is 1-1/6, or 5/6 • Not independent: One occurs affects probability that other
– Note: when using p, complement is often q occurs
– Probability both occur P(A and B) = P(A) x P(B | A)
• Mutually exclusive: Have no simple outcomes • Where P(B | A) means the prob B given A happened
in common – can’t both occur in same – e.g., MMO has 10% mages, 40% warriors, 80% Boss defeated.
Probability Boss fights mage and is defeated?
experiment – You might think that = P(mage) x P(defeat B) = .10 * .8 = .08
P(A or B) = P(A) + P(B) – But likely not independent. P(defeat B | mage) < 80%. So, need
not-independent formula P(mage)* P(defeat B | mage)
– e.g., d6: P(3 or 6) = P(3) + P(6) = 1/6 + 1/6 = 2/6

Probability Example Probability Example

• Probability drawing King? • Probability drawing King?


P(K) = ¼
• Draw, put back. Now?

2
4/27/2017

Probability Example Probability Example

• Probability drawing King? • Probability drawing King?


P(K) = ¼ P(K) = ¼
• Draw, put back. Now? • Draw, put back. Now?
P(K) = ¼ P(K) = ¼
• Probability not King? • Probability not King?
P(K’) = 1-P(K) = ¾
• Draw, put back. 2 Kings?

Probability Example Probability Example


• Draw. King or Queen?

• Probability drawing King? • Probability drawing King?


P(K) = ¼ P(K) = ¼
• Draw, put back. Now? • Draw, put back. Now?
P(K) = ¼ P(K) = ¼
• Probability not King? • Probability not King?
P(K’) = 1-P(K) = ¾ P(K’) = 1-P(K) = ¾
• Draw, put back. 2 Kings? • Draw, put back. 2 Kings?
P(K) x P(K) = ¼ x ¼ = 1/16

Probability Example Probability Example


• Draw. King or Queen? • Draw. King or Queen?
P(K or Q) = P(K) + P(Q) P(K or Q) = P(K) + P(Q)
=¼+¼=½ =¼+¼=½
• Draw, put back. Not 2
• Probability drawing King? • Probability drawing King? Kings?
P(K) = ¼ P(K) = ¼
• Draw, put back. Now? • Draw, put back. Now?
P(K) = ¼ P(K) = ¼
• Probability not King? • Probability not King?
P(K’) = 1-P(K) = ¾ P(K’) = 1-P(K) = ¾
• Draw, put back. 2 Kings? • Draw, put back. 2 Kings?
P(K) x P(K) = ¼ x ¼ = 1/16 P(K) x P(K) = ¼ x ¼ = 1/16

3
4/27/2017

Probability Example Probability Example


• Draw. King or Queen? • Draw. King or Queen?
P(K or Q) = P(K) + P(Q) P(K or Q) = P(K) + P(Q)
=¼+¼=½ =¼+¼=½
• Draw, put back. Not 2 • Draw, put back. Not 2
• Probability drawing King? Kings? • Probability drawing King? Kings?
P(K) = ¼ P(K’) x P(K’) = ¾ x ¾ = 9/16 P(K) = ¼ P(K’) x P(K’) = ¾ x ¾ = 9/16
• Draw, put back. Now? • Draw, don’t put back. • Draw, put back. Now? • Draw, don’t put back.
P(K) = ¼ Not 2 Kings? P(K) = ¼ Not 2 Kings?
• Probability not King? • Probability not King? P(K’) x P(K’ | K’) = ¾ x 2/3
P(K’) = 1-P(K) = ¾ P(K’) = 1-P(K) = ¾ = 6/12 = ½
• Draw, put back. 2 Kings? • Draw, put back. 2 Kings? • Draw, don’t put back.
P(K) x P(K) = ¼ x ¼ = 1/16 P(K) x P(K) = ¼ x ¼ = 1/16 King 2nd card?

Probability Example Outline


• Draw. King or Queen?
P(K or Q) = P(K) + P(Q)
=¼+¼=½
• Intro (done)
• Draw, put back. Not 2 • Probability (done)
• Probability drawing King? Kings? • Probability Distributions (next)
P(K) = ¼ P(K’) x P(K’) = ¾ x ¾ = 9/16
• Draw, put back. Now? • Draw, don’t put back.
P(K) = ¼ Not 2 Kings?
• Probability not King? P(K’) x P(K’ | K’) = ¾ x 2/3
P(K’) = 1-P(K) = ¾ = 6/12 = ½
• Draw, put back. 2 Kings? • Draw, don’t put back.
P(K) x P(K) = ¼ x ¼ = 1/16 King 2nd card?
P(K’) x P(K | K’) = ¾ x ⅓ = 3/12 = ¼

Probability Distributions Uniform Distribution

• Probability distribution –
values and likelihood of • “So what?”
those values that random • Can use known
variable can take
• Why? If can model formulas
mathematically, can use to
predict occurrences
– e.g., probability slot machine https://goo.gl/jqomFI

pays out on given day


– e.g., probability game server Types discussed: Mean = (1 + 6) / 2 = 3.5
hosts player today Uniform (discrete) Variance = ((6 – 1 + 1)2 – 1)/12
Binomial (discrete) = 2.9
– e.g., probability certain game
mode is chosen by player Poisson (discrete)
Normal (continuous) Std Dev = sqrt(Variance) = 1.7
– Also, some statistical
techniques for some
distributions only

4
4/27/2017

Binomial Distribution Example (1 of 3) Binomial Distribution Example (1 of 3)


How to assign probabilities? How to assign probabilities?

• Could measure (empirical)


• Suppose toss 3 coins • Suppose toss 3 coins – Q: how?
• Could use “hunch”
• Random variable • Random variable
(subjective)
X = number of heads X = number of heads – Q: what do you think?
• Want to know probability • Want to know probability • Could use theory
of exactly 2 heads of exactly 2 heads (classical)
P(X=2) = ? P(X=2) = ? – Math using our probability
rules (not shown)
– Enumerate (next)

Binomial Distribution Example (2 of 3) Binomial Distribution Example (3 of 3)

http://web.mnstate.edu/peil/MDEV102/U3/S25/Cartesian3.PNG

http://www.mathnstuff.com/math/spoken/here/2class/90/binom2.gif

All equally likely (p is 1/8 for each)


Can draw histogram of
 P(HHT) + P(HTH) + P(THH) = 3/8 These are all binomial distributions
number of heads

Binomial Distribution (1 of 2) Binomial Distribution (2 of 2)


• In general, any number of • Characteristics of • “So what?”
trials (n) & any probability experiment that gives
of successful outcome (p) random number with • Can use known formulas
(e.g., heads) binomial distribution:
– Experiment consists of n
identical trials.
– Each trial results in only two
possible outcomes, S or F
http://www.s-cool.co.uk/gifs/a-mat-sdisc-dia08.gif
– Probability of S each trial is
same, denoted p
– Trials are independent
– Random variable of interest Excel: binom.dist()
(X) is number of S’s in n trials
– 2 heads, 3 flips
http://www.vassarstats.net/textbook/f0603.gif =binom.dist(2,3,0.5,FALSE)
=0.375 (i.e., 3/8) http://www.s-cool.co.uk/gifs/a-mat-sdisc-dia12.gif

5
4/27/2017

Poisson Distribution Poisson Distributions?


• Distribution of probability of events occurring in Not Poisson Probably Poisson
certain interval (broken into units) • Number of people arriving at • Number of logins to MMO
restaurant during dinner hour during prime time
– Interval can be time, area, volume, distance – People frequently arrive in • Number of groups arriving
– e.g., number of players arriving at server lobby in 5- groups
at restaurant during dinner
minute period between noon-1pm • Number of students register
for course in BannerWeb per hour
• Requires hour on first day of • Number of defects (bugs)
1. Probability of event same for all units registration per 100 lines of code
2. Number of events in one unit independent of
– Prob not equal – most register • People arriving at cash
in first few hours
register (if they shop
number of events in any other unit – Not independent – if too many
individually)
register early, system crashes
3. Events occur singly (not simultaneously). In other
words, as unit gets smaller, probability of two events
Phrase people use is “random arrivals”
occurring approaches 0

Poisson Distribution Poisson Distribution Example


• Distribution of probability of events occurring • Number of games student plays per day averages
one per day
in certain interval
• Number of games played per day independent of
all other days
• Can only play 1 game at a time
• What’s probability of playing two games next
day?
• In this case, the value of λ = 1

http://www.dummies.com/education/math/business-statistics/how-to-compute-poisson-probabilities/

Poisson Distribution Outline


• “So what?”  Known formulas • Intro (done)
• Probability (done)
• Mean = λ
• Probability Distributions
• Variance = λ – Discrete (done)
• Std Dev = sqrt (λ)
So far random variable could take only discrete
Excel: poisson.dist() set of values
1 game per day, chance for 2
= poisson.dist(2,1,false)
= 0.18394
Q: What does that mean?
Q: What other distributions might we consider?

6
4/27/2017

Outline Continuous Distributions


• Many random variables are • So, continuous distributions
• Intro (done) continuous have probability density, f(x)
• Probability (done) – e.g., recording time (time to
perform service) or
 How to use to calculate
measuring something (height,
probabilities?
• Probability Distributions weight, strength) • Don’t care about specific
• For continuous, doesn’t values
– Discrete (done) make sense to talk about – e.g., P(Height =
P(X=x)  continuum of 60.1946728163 inches)
– Continuous (next) • Instead, ask about range of
possible values for X
– Mathematically, if all non- values
zero, total probability infinite – e.g., P(59.5 < X < 60.5)
(this violates our rule) • Uses calculus (integrate
area under curve) (not
shown here)
What continuous distribution is especially important?

Continuous Distributions Normal Distribution (1 of 2)


• Many random variables are • So, continuous distributions • “Bell-shaped” or “Bell-curve”
continuous have probability density, f(x) – Distribution from -∞ to +∞
– e.g., recording time (time to  How to use to calculate • Symmetric
perform service) or probabilities?
measuring something (height, • Mean, median, mode all
weight, strength) • Don’t care about specific same
• For continuous, doesn’t values – Mean determines location, 50% area 50% area
make sense to talk about – e.g., P(Height = standard deviation determines to left to right
60.1946728163 inches) “width”
P(X=x)  continuum of
possible values for X • Instead, ask about range of • Super important! -∞ +∞
– Mathematically, if all non- values – Lots of distributions follow https://www.mathsisfun.com/data/images/normal-distribution-2.svg

zero, total probability infinite – e.g., P(59.5 < X < 60.5) normal (“bell curve”)
(this violates our rule) – Basis for inferential statistics
• Uses calculus (integrate (e.g., statistical tests)
area under curve) (not – “Bridge” between probability Aka “Gaussian” distribution
shown here) and statistics
What continuous distribution is especially important?  The Normal Distribution

Normal Distribution (2 of 2) Standard Normal Distribution


• Many normal green - mean -3, std dev 0.5 • Standardize • Mean μ = 0
distributions
red - mean 0, std dev 1 – Subtract mean • Standard Deviation σ = 1
black - mean 2, std dev 3 – Divide by standard
deviation
• Total area under curve = 1
– Sounds like probability!
• However, “the” normal
distribution refers to
standard normal
Use to predict how
– Subtract mean (μ) likely an observed
– Divide by standard sample is given a
deviation (σ) population mean

http://images.slideplayer.com/10/2753952/slides/slide_2.jpg
=norm.dist()

7
4/27/2017

Using the Standard Normal Using the Standard Normal


Z = (x - μ) / σ Z = (x - μ) / σ
• Suppose League of = (30 - 24) / 3 • Suppose League of = (30 - 24) / 3
Legends Champion =2 Legends Champion =2
released once every 24 released once every 24
• Want to know P(Z > 2) • Want to know P(Z > 2)
days on average, days on average,
standard deviation of 3 standard deviation of 3
days days
• What is the probability • What is the probability
Champion released 30+ Champion released 30+
days? days?
• x = 30, μ = 24, σ = 3 http://ci.columbia.edu/ci/premba_test/c0331/s6/s6_4.html
• x = 30, μ = 24, σ = 3 http://ci.columbia.edu/ci/premba_test/c0331/s6/s6_4.html

=norm.dist(x,mean,stddev,false)
Use table (Z-table). Or Empirical Rule? =norm.dist(30,24,3,false) Use table (Z-table). Or Empirical Rule?
 5% / 2 = 2.5% likely (actual is 2.28%)

Test for Normality Normality Testing with a Histogram


• Why? • Use histogram shape to look for “bell curve”
– Use some inferential statistics (parametric tests)
– Can use Empirical Rule
• How? Several ways. One:
– Normal probability plot – graphical technique to
see if data set is approximately normally
distributed
http://2.bp.blogspot.com/_g8gh7I4zSt4/TR85eGJlMfI
/AAAAAAAAAQs/PaOHJsjonPM/s1600/histo.JPG http://seankross.com/img/biqq.png

Yes No

Normality Testing with a Histogram Normality Testing with a Histogram

http://www.sascommunity.org/planet/blog/category/statistical-thinking/ http://www.sascommunity.org/planet/blog/category/statistical-thinking/

They are all from normal distribution! Suffer from:


- Binning (not continuous)
Q: What distributions are these from? Any normal? - Few samples (15)

8
4/27/2017

Normality Testing with a Quantile-


Quantile-Quantile Plot Example
Quantile Plot
• Quantiles of one
• Do the following values come from a normal
https://goo.gl/rLLSIQ

versus another
• If line  same distribution?
distribution

1. Order data 7.19, 6.31, 5.89, 4.5, 3.77, 4.25, 5.19, 5.79, 6.79
2. Compute Z
scores
(normal) 1. Order data
3. Plot data (y-
axis) versus Z 2. Compute Z scores
(x-axis)
• Normal?  line 3. Plot data versus Z

http://www.statisticshowto.com/q-q-plots/

Quantile-Quantile Plot Example – Quantile-Quantile Plot Example –


Order Data Compute Z scores
Unordered Ordered (low to high)
7.19 3.77
6.31 4.25 Divide into 10% = ?
N+1 = 10 20% = ?
5.89 4.50
30% = ?
4.50 5.19 40% = ?
3.77 5.89 50% = 0
60% = ?
4.25 5.79
70% = ?
5.19 6.31 80% = ?
5.79 6.79 90% = ?
6.79 7.19
Want Z-score for that segment
Lookup in Z-table
N = 9 data points
http://www.statisticshowto.com/q-q-plots/ http://www.statisticshowto.com/q-q-plots/

Z-Table Quantile-Quantile Plot Example –


• Tells what cumulative percentage of the standard normal
curve is under any point (Z-score). Or, P(-∞ to Z) Compute Z scores
e.g., 80%?

10% = -1.28
20% = -0.84
30% = -0.52
40% = -0.25 10% = -1.28
50% = 0 20% = -0.84
30% = -0.52
60% = 0.25 40% = -0.25
50% = 0
70% = 0.52 60% = 0.25
80% = 0.84 70% = 0.52
80% = 0.84
90% = 1.28 90% = 1.28

=NORMSINV(area) – provide Z for


(Note: Above for positive Z-scores – area under standard normal curve
(Only some points shown)
also negative tables, or subtract 0.5) =NORMSINV(.80)
=0.841621

9
4/27/2017

Quantile-Quantile Plot Example – Plot Quantile-Quantile Plots in Excel


• Mostly, a manual process. Do as per above.
• Example of step by step process (with spreadsheet):
http://facweb.cs.depaul.edu/cmiller/it223/normQuant.html

Linear?  Normal https://i2.wp.com/www.real-statistics.com/wp-content/uploads/2012/12/qq-plot-normality.jpg

http://www.statisticshowto.com/q-q-plots/

Examples of Normality Testing with a


Quantile-Quantile Plot

http://d2vlcm61l7u1fs.cloudfront.net/media%2Fb95%2Fb953e7cd-31c3-45b0-a8ec-03b0e81c95d1%2Fphp2Y86od.png

10

You might also like