Tải bản đầy đủ - 0 (trang)
Hack 45. Amaze Your 23 Closest Friends

# Hack 45. Amaze Your 23 Closest Friends

Tải bản đầy đủ - 0trang

GettingStarted

Todeterminethechancesofatleasttwopeoplesharinga

birthday,wehavetomakeacoupleofreasonableassumptions

birthdaysareuniformlydistributedinthepopulation.This

oneverysingledayoftheyear.

Thisisnotnecessarilyperfectlytrue,butit'scloseenoughfor

ustostilltrustourresults.However,thereisonebirthdayfor

whichthisisdefinitelynottrue:February29,whichoccursonly

everyfouryearsonLeapYear.Thegoodnewsisthatfew

enoughpeoplearebornonFebruary29thatitiseasyforusto

justignoreitandstillgetaccurateestimates.

birthdayproblemwithrelativeease.

ApplyingtheLawofTotalProbability

Inourproblem,thereareonlytwomutuallyexclusivepossible

outcomes:

Atleasttwopeopleshareabirthday.

Noonesharesabirthday.

Sinceoneofthesetwothingsmustoccur,thesumofthetwo

probabilitieswillalwaysbeequaltoone.Statisticianscallthis

theLawofTotalProbability,anditcomesinhandyforthis

problem.

Thetermmutuallyexclusivemeansthatifoneeventoccurs,theother

onecannotoccur,andviceversa.

Asimplecoin-flippingexamplecanhelppicturehowthisworks.

theprobabilityofgettingatailsis0.5(whichisanother

exampleofmutuallyexclusiveevents,becausethecoincan't

(0.5+0.5).Conversely,wecanthinkoftheprobabilityof

viceversa.

Sometimes,it'seasiertodeterminetheprobabilityofanevent

notoccurringandthenusethatinformationtodeterminethe

probabilitythatitwilloccur.Theprobabilityofnoonesharinga

birthdayisabiteasiertofigureout,anditdependsonlyonhow

manypeopleareinthegroup.

Imaginethatourgroupcontainsonlytwopeople.What'sthe

probabilitythattheyshareabirthday?Well,theprobabilitythat

theydon'tshareabirthdayiseasytofigure:person#1has

somebirthday,andthereare364otherbirthdaysperson#2

mighthavethatwouldresultinthemnotsharingabirthday.So,

mathematically,it's364dividedby365(thetotalnumberof

possiblebirthdays),or0.997.

Sincetheprobabilityofthetwopeoplenotsharingabirthdayis

0.997(averyhighprobability),theprobabilityofthemactually

sharingabirthdayisequalto1-0.997(0.003,averylow

probability).Thismeansthatonly3outofevery1,000

randomlyselectedpairsofpeoplewillshareabirthday.Sofar,

thismakesperfectlogicalsense.However,thingschange(and

CalculatingtheProbabilityofIndependent

Events

Theothertrickweneedtosolveourproblemisapplyingthe

ideaofindependentevents.Two(ormore)eventsaresaidtobe

independentiftheprobabilityoftheirco-occurrenceisequalto

theproductoftheirindividualprobabilities.

Onceagain,thisissimpletounderstandwithanice,easycoinflippingexample.Ifyouflipacointwice,theprobabilityof

theoutcomeofonecoinfliphasnoinfluenceontheoutcomeof

theother(hence,theyareindependentevents).

So,whenyouflipacointwice,oneoutofeveryfourtimesthe

onlyonetimeoutofeveryeight.

person'sbirthdaydoesn'tinfluenceanyoneelse'sbirthday),and

thuswe'llbeabletofigureouttheprobabilityofatleasttwoof

thosepeoplesharingabirthday,regardlessofhowmanypeople

Toreview,nomatterhowmanypeopleareinourgroup,only

oneoftwomutuallyexclusiveeventscanoccur:atleasttwo

peopleshareabirthdayornoonesharesabirthday.Becauseof

theLawofTotalProbability,weknowthatwecandeterminethe

probabilityofnoonesharingabirthday,andoneminusthat

valuewillbeequaltotheprobabilitythatatleasttwosharea

birthday.Lastly,wealsoknowthateachperson'sbirthdayis

independentoftheothergroupmembers.Gotallthat?Good,

let'sproceed!

SolvingtheBirthdayProblem

sharingabirthdayinagroupoftwoisequalto0.997.Let'ssay

noonesharingabirthday?Thereare363otherbirthdays

person#3couldhavethatwouldresultinnoneofthemsharing

abirthday.Theprobabilityofperson#3notsharingabirthday

withtheothertwoistherefore363/365,or0.995(slightly

lower).

Butremember,we'reinterestedintheprobabilitythatnoone

sharesabirthday,soweusetheruleofindependenteventsand

multiplytheprobabilitythatthefirsttwowon'tshareabirthday

bytheprobabilitythatthethirdpersonwon'tshareabirthday

withtheothertwo:0.997x0.995=0.992.So,inagroupof

threepeople,theprobabilitythatnoneofthemshareabirthday

is0.992,whichmeansthattheprobabilitythatatleasttwoof

themshareabirthdayis0.008(1-0.992).

Thismeansthatonly8outofevery1,000randomlyselected

groupsof3peoplewillresultinatleast2ofthemsharinga

birthday.Thisisstillaprettysmallchance,butnotethatthe

probabilityhasmorethandoubledbymovingfromtwopeople

tothree(0.003comparedto0.008)!

probabilityofatleasttwopeoplesharingabirthdaystartsto

increaseveryquickly.Bythetimeourgroupofpeopleisupto

10,theprobabilityofatleast2sharingabirthdayisupto

0.117.Howdowedeterminethisingeneral?Foreveryperson

denominator,andthenumeratorwillbe365minusthenumber

So,forourpreviouslymentionedgroupof10people,the

numeratorforthelastfractionis356(365-9),determinedlike

so:

Thistellsusthattheprobabilityofnoonesharingabirthdayin

agroupof10peopleisequalto0.883(muchlowerthanwhat

wesawfor2or3people),sotheprobabilitythatatleast2of

themwillshareabirthdayis0.117(1-0.883).

Thefirstfractionistheprobabilitythatthesecondpersonwon't

shareabirthdaywiththefirstperson.Thesecondfractionisthe

probabilitythatthethirdpersonwon'tshareabirthdaywiththe

firsttwo.Thethirdfractionistheprobabilitythatthefourth

personwon'tshareabirthdaywiththefirstthree,andsoon.

Theninthandfinalfractionistheprobabilitythatthetenth

personwon'tshareabirthdaywithanyoftheothernine.

Inorderfornoonetoshareabirthday,everysingleoneoftheevents

inthechainhastoco-occur,sowedeterminetheprobabilityofallof

themhappeninginthesamegroupofpeoplebymultiplyingallofthe

includeanotherfractionintotheequation,whichmakesthefinal

productgetsmallerandsmaller.

SolvingforAlmostAnyGroupSize

Asthegroupsizeincreases,itbecomesincreasinglymorelikely

thatatleasttwopeoplewillshareabirthday.Thismakes

perfectsense,butwhatsurprisesmostpeopleishowquickly

theprobabilityincreasesasthegroupgetsbigger.Figure4-3

illustratestherateatwhichtheprobabilitygoesupwhenyou

Figure4-3.Chancesofmatchingbirthdays

For20people,theprobabilityis0.411;for30people,it's0.706

(meaningthat7timesoutof10youwillwinmoneyonyour

bet,whichareprettygoododds).Ifyouhave23peopleinyour

group,thechancesarejustslightlybetterthan50/50thatat

least2peoplewillshareabirthday(theprobabilityisequalto

0.507).

Whenallissaidanddone,thisisaprettyneattrickthatnever

ceasestosurprisepeople.Butremembertomakethebarbet

onlyifyouhaveatleast23peopleintheroom(andyou're

willingtoaccept50/50odds).Itworksevenbetterwithmore

people,becauseyourchancesofwinninggoupdramatically

percentchanceofwinningyourbet,you'llneed41peopleinthe

room(probabilityofatleast2peoplesharingabirthday=

0.903).With50people,there'sa97percentchanceyou'llwin

yourmoney.Onceyouhave60peopleormore,youare

practicallyguaranteedtohaveatleast2peopleintheroom

whoshareabirthdayand,ofcourse,ifyouhave366people

present,thereisa100percentchanceofatleast2people

sharingabirthday.Thosearegreatoddsifyoucanget

someonetotakethebet!

WilliamSkorupski

Hack46.DesignYourOwnBarBet

software,youcanfiguretheprobabilitiesassociatedwith

allsortsof"spontaneous"friendlywagers.

Severalofthestatisticshackselsewhereinthischapteruse

decksofcards[Hack#42]ordice[Hack#43]aspropsto

demonstratehowsomeseeminglyrareandunusualoutcomes

arefairlycommon.Assomeonewho'sinterestedineducating

theworldonstatisticalprinciples,younodoubtwillwishtouse

theseteachingexamplestoimpressandinstructothers.Hey,if

youhappentowinalittlemoneyalongtheway,that'sjustone

ofthebenefitsofateacher'slife.

Butthere'snoneedtorelyonthespecificexamplesprovided

here,oreventocarrycardsanddicearound(though,knowing

youthewayIthinkIdo,youmighthaveplentyofother

reasonstocarrycardsanddicearound).Hereareacoupleof

basicprinciplesyoucanusetomakeupyourownbarbetwith

anyknowndistributionofdata,suchasthealphabet,numbers

from1to100,andsoon:

Principle1

Anunlikelyeventincreasesinlikelihoodifthereare

repeatedopportunitiesforittooccur.

Principle2

Iftherearealargenumberofpossibleevents,thechance

ofanyspecificeventoccurringseemssmall.

Therestofthishackwillshowyouhowtousetheseprinciples

Principle1

Theprobabilityofanygiveneventoccurringisequaltothe

numberofoutcomes,whichequaltheeventdividedbythe

numberofpossibleoutcomes.Forexample,whatarethe

chancesthatyouandIwereborninthesamemonth?

Pretendingforasecondthatbirthsaredistributedequally

acrossallmonths,theprobabilityis1/12.Thereisonlyone

outcomethatcountsasamatch(yourbirthmonth),andthere

are12possibleoutcomes(the12monthsoftheyear).

thisbookhasthesamebirthmonthasme?Intuitively,that

shouldbeabitmorelikelythan1outof12.Theformulato

figurethisoutisnotquiteassimpleasonewouldlike,

unfortunately.Itisnot1/12timesitself,forexample.That

wouldproduceasmallerprobabilitythanwebeganwith(i.e.,

1/24).Noristheformula1/12+1/12.Though2/12seemsto

indicatingagreaterlikelihoodthanbeforethesesortsof

withmybirthmonthamongthe12isobviouslynot12/12,

becausethatwouldguaranteeamatch.

Theactualformulaforcomputingthechancesofanevent

occurringacrossmultipleopportunitiesisbasedonthenotionof

takingtheproportionalchancethataneventwillnothappen