Part 1 Descriptive statistics & notation Vocabulary growth curve our sample: recently , very , not , otherwise , much , very , very , merely , not , now , very , much , merely , not , very โฎ N = 1, V ( N ) = 1, V 1 ( N ) = 1 โฎ N = 3, V ( N ) = 3, V 1 ( N ) = 3 โฎ N = 7, V ( N ) = 5, V 1 ( N ) = 4 โฎ N = 12, V ( N ) = 7, V 1 ( N ) = 4 Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 15 / 99
Part 1 Descriptive statistics & notation Vocabulary growth curve our sample: recently , very , not , otherwise , much , very , very , merely , not , now , very , much , merely , not , very โฎ N = 1, V ( N ) = 1, V 1 ( N ) = 1 โฎ N = 3, V ( N ) = 3, V 1 ( N ) = 3 โฎ N = 7, V ( N ) = 5, V 1 ( N ) = 4 โฎ N = 12, V ( N ) = 7, V 1 ( N ) = 4 โฎ N = 15, V ( N ) = 7, V 1 ( N ) = 3 Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 15 / 99
Part 1 Descriptive statistics & notation Vocabulary growth curve our sample: recently , very , not , otherwise , much , very , very , merely , not , now , very , much , merely , not , very vocabulary growth curve: adverbs 10 V ( N ) V 1 ( N ) 8 โฎ N = 1, V ( N ) = 1, V 1 ( N ) = 1 โฎ N = 3, V ( N ) = 3, V 1 ( N ) = 3 V ( N ) V 1 ( N ) 6 โฎ N = 7, V ( N ) = 5, V 1 ( N ) = 4 4 โฎ N = 12, V ( N ) = 7, V 1 ( N ) = 4 2 โฎ N = 15, V ( N ) = 7, V 1 ( N ) = 3 0 0 2 4 6 8 10 12 14 N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 15 / 99
Part 1 Descriptive statistics & notation A realistic vocabulary growth curve: the Brown corpus vocabulary growth curve: Brown corpus 50000 V ( N ) V 1 ( N ) 40000 30000 V ( N ) V 1 ( N ) 20000 10000 0 0e+00 2e+05 4e+05 6e+05 8e+05 1e+06 N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 16 / 99
Part 1 Descriptive statistics & notation Vocabulary growth in authorship attribution โฎ Authorship attribution by n-gram tracing applied to the case of the Bixby letter (Grieve et al. submitted) โฎ Word or character n-grams in disputed text are compared against large โtrainingโ corpora from candidate authors 323 Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 17 / 99
Part 1 Descriptive statistics & notation Observing Zipfโs law across languages and different linguistic units Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 18 / 99
Part 1 Descriptive statistics & notation Observing Zipfโs law The Italian prefix ri- in the la Repubblica corpus Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 19 / 99
Part 1 Descriptive statistics & notation Observing Zipfโs law Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 20 / 99
Part 1 Descriptive statistics & notation Observing Zipfโs law Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 20 / 99
Part 1 Descriptive statistics & notation Observing Zipfโs law โฎ Straight line in double-logarithmic space corresponds to power law for original variables โฎ This leads to Zipfโs (1949; 1965) famous law: f r = C r a Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 21 / 99
Part 1 Descriptive statistics & notation Observing Zipfโs law โฎ Straight line in double-logarithmic space corresponds to power law for original variables โฎ This leads to Zipfโs (1949; 1965) famous law: f r = C r a โฎ If we take logarithm on both sides, we obtain: log f r = log C โ a ยท log r Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 21 / 99
Part 1 Descriptive statistics & notation Observing Zipfโs law โฎ Straight line in double-logarithmic space corresponds to power law for original variables โฎ This leads to Zipfโs (1949; 1965) famous law: f r = C r a โฎ If we take logarithm on both sides, we obtain: log f r = log C โ a ยท log r ๏ฟฝ ๏ฟฝ๏ฟฝ ๏ฟฝ ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ y x Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 21 / 99
Part 1 Descriptive statistics & notation Observing Zipfโs law โฎ Straight line in double-logarithmic space corresponds to power law for original variables โฎ This leads to Zipfโs (1949; 1965) famous law: f r = C r a โฎ If we take logarithm on both sides, we obtain: log f r = log C โ a ยท log r ๏ฟฝ ๏ฟฝ๏ฟฝ ๏ฟฝ ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ y x โฎ Intuitive interpretation of a and C : โฎ a is slope determining how fast log frequency decreases โฎ log C is intercept , i.e. log frequency of most frequent word ( r = 1 โ log r = 0) Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 21 / 99
Part 1 Descriptive statistics & notation Observing Zipfโs law Least-squares fit = linear regression in log-space (Brown corpus) Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 22 / 99
Part 1 Descriptive statistics & notation Zipf-Mandelbrot law Mandelbrot (1953, 1962) โฎ Mandelbrotโs extra parameter: C f r = ( r + b ) a โฎ Zipfโs law is special case with b = 0 Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 23 / 99
Part 1 Descriptive statistics & notation Zipf-Mandelbrot law Mandelbrot (1953, 1962) โฎ Mandelbrotโs extra parameter: C f r = ( r + b ) a โฎ Zipfโs law is special case with b = 0 โฎ Assuming a = 1, C = 60,000, b = 1: โฎ For word with rank 1, Zipfโs law predicts frequency of 60,000; Mandelbrotโs variation predicts frequency of 30,000 โฎ For word with rank 1,000, Zipfโs law predicts frequency of 60; Mandelbrotโs variation predicts frequency of 59.94 Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 23 / 99
Part 1 Descriptive statistics & notation Zipf-Mandelbrot law Mandelbrot (1953, 1962) โฎ Mandelbrotโs extra parameter: C f r = ( r + b ) a โฎ Zipfโs law is special case with b = 0 โฎ Assuming a = 1, C = 60,000, b = 1: โฎ For word with rank 1, Zipfโs law predicts frequency of 60,000; Mandelbrotโs variation predicts frequency of 30,000 โฎ For word with rank 1,000, Zipfโs law predicts frequency of 60; Mandelbrotโs variation predicts frequency of 59.94 โฎ Zipf-Mandelbrot law forms basis of statistical LNRE models โฎ ZM law derived mathematically as limiting distribution of vocabulary generated by a character-level Markov process Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 23 / 99
Part 1 Descriptive statistics & notation Zipf-Mandelbrot law Non-linear least-squares fit (Brown corpus) Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 24 / 99
Part 1 Some examples (zipfR) Outline Part 1 Motivation Descriptive statistics & notation Some examples (zipfR) LNRE models: intuition LNRE models: mathematics Part 2 Applications & examples (zipfR) Limitations Non-randomness Conclusion & outlook Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 25 / 99
Part 1 Some examples (zipfR) zipfR Evert and Baroni (2007) โฎ http://zipfR.R-Forge.R-Project.org/ โฎ Conveniently available from CRAN repository โฎ Package vignette = gentle tutorial introduction Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 26 / 99
Part 1 Some examples (zipfR) First steps with zipfR โฎ Set up a folder for this course, and make sure it is your working directory in R (preferably as an RStudio project) โฎ Install the most recent version of the zipfR package โฎ Package, handouts, code samples & data sets available from http://zipfr.r-forge.r-project.org/lrec2018.html > library(zipfR) > ?zipfR # documentation entry point > vignette("zipfr-tutorial") # read the zipfR tutorial Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 27 / 99
Part 1 Some examples (zipfR) Loading type-token data โฎ Most convenient input: sequence of tokens as text file in vertical format (โone token per lineโ) โ mapped to appropriate types: normalized word forms, word pairs, lemmatized, semantic class, n-gram of POS tags, . . . โ language data should always be in UTF-8 encoding! โ large files can be compressed ( .gz , .bz2 , .xz ) Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 28 / 99
Part 1 Some examples (zipfR) Loading type-token data โฎ Most convenient input: sequence of tokens as text file in vertical format (โone token per lineโ) โ mapped to appropriate types: normalized word forms, word pairs, lemmatized, semantic class, n-gram of POS tags, . . . โ language data should always be in UTF-8 encoding! โ large files can be compressed ( .gz , .bz2 , .xz ) โฎ Sample data: brown_adverbs.txt on tutorial homepage โฎ lowercased adverb tokens from Brown corpus (original order) โ download and save to your working directory Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 28 / 99
Part 1 Some examples (zipfR) Loading type-token data โฎ Most convenient input: sequence of tokens as text file in vertical format (โone token per lineโ) โ mapped to appropriate types: normalized word forms, word pairs, lemmatized, semantic class, n-gram of POS tags, . . . โ language data should always be in UTF-8 encoding! โ large files can be compressed ( .gz , .bz2 , .xz ) โฎ Sample data: brown_adverbs.txt on tutorial homepage โฎ lowercased adverb tokens from Brown corpus (original order) โ download and save to your working directory > adv <- readLines("brown_adverbs.txt", encoding="UTF-8") > head(adv, 30) # mathematically, a โโvectorโโ of tokens > length(adv) # sample size = 52,037 tokens Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 28 / 99
Part 1 Some examples (zipfR) Descriptive statistics: type-frequency list > adv.tfl <- vec2tfl(adv) > adv.tfl k f type 1 1 4859 not 2 2 2084 nโt 3 3 1464 so 4 4 1381 only 5 5 1374 then 6 6 1309 now 7 7 1134 even 8 8 1089 as . . . . . . . . . N V 52037 1907 > N(adv.tfl) # sample size > V(adv.tfl) # type count Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 29 / 99
Part 1 Some examples (zipfR) Descriptive statistics: frequency spectrum > adv.spc <- tfl2spc(adv.tfl) # or directly with vec2spc > adv.spc m Vm 1 1 762 2 2 260 3 3 144 4 4 99 5 5 69 6 6 50 7 7 40 8 8 34 . . . . . . N V 52037 1907 > N(adv.spc) # sample size > V(adv.spc) # type count Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 30 / 99
Part 1 Some examples (zipfR) Descriptive statistics: vocabulary growth โฎ VGC lists vocabulary size V ( N ) at different sample sizes N โฎ Optionally also spectrum elements V m ( N ) up to m.max > adv.vgc <- vec2vgc(adv, m.max=2) โฎ Visualize descriptive statistics with plot method > plot(adv.tfl) # Zipf ranking > plot(adv.tfl, log="xy") # logarithmic scale recommended > plot(adv.spc) # barplot of frequency spectrum > plot(adv.vgc, add.m = 1:2) # vocabulary growth curve Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 31 / 99
Part 1 Some examples (zipfR) Further example data sets ?Brown words from Brown corpus ?BrownSubsets various subsets ?Dickens words from novels by Charles Dickens ?ItaPref Italian word-formation prefixes ?TigerNP NP and PP patterns from German Tiger treebank ?Baayen2001 frequency spectra from Baayen (2001) ?EvertLuedeling2001 German word-formation affixes (manually corrected data from Evert and Lรผdeling 2001) Practice: โฎ Explore these data sets with descriptive statistics โฎ Try different plot options (from help pages ?plot.tfl , ?plot.spc , ?plot.vgc ) Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 32 / 99
Part 1 LNRE models: intuition Outline Part 1 Motivation Descriptive statistics & notation Some examples (zipfR) LNRE models: intuition LNRE models: mathematics Part 2 Applications & examples (zipfR) Limitations Non-randomness Conclusion & outlook Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 33 / 99
Part 1 LNRE models: intuition Motivation โฎ Interested in productivity of affix, vocabulary of author, . . . ; not in a particular text or sample โ statistical inference from sample to population โฎ Discrete frequency counts are difficult to capture with generalizations such as Zipfโs law โฎ Zipfโs law predicts many impossible types with 1 < f r < 2 โ population does not suffer from such quantization effects Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 34 / 99
Part 1 LNRE models: intuition LNRE models โฎ This tutorial introduces the state-of-the-art LNRE approach proposed by Baayen (2001) โฎ LNRE = Large Number of Rare Events โฎ LNRE uses various approximations and simplifications to obtain a tractable and elegant model โฎ Of course, we could also estimate the precise discrete distributions using MCMC simulations, but . . . 1. LNRE model usually minor component of complex procedure 2. often applied to very large samples ( N > 1 M tokens) Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 35 / 99
Part 1 LNRE models: intuition The LNRE population โฎ Population: set of S types w i with occurrence probabilities ฯ i โฎ S = population diversity can be finite or infinite ( S = โ ) โฎ Not interested in specific types โ arrange by decreasing probability: ฯ 1 โฅ ฯ 2 โฅ ฯ 3 โฅ ยท ยท ยท โ impossible to determine probabilities of all individual types โฎ Normalization: ฯ 1 + ฯ 2 + . . . + ฯ S = 1 โฎ Need parametric statistical model to describe full population (esp. for S = โ ), i.e. a function i ๏ฟฝโ ฯ i โฎ type probabilities ฯ i cannot be estimated reliably from a sample, but parameters of this function can โฎ NB: population index i ๏ฟฝ = Zipf rank r Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 36 / 99
Part 1 LNRE models: intuition Examples of population models 0.10 0.10 โ 0.08 0.08 โโโโ โ โ โ 0.06 โ 0.06 โ โ โ โ ฯ k โ ฯ k โ โ 0.04 0.04 โ โ โ โ โ โ โ โ โ โ 0.02 0.02 โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ โ โโโโโโโโโโโโโโโโโโโโโ 0.00 0.00 0 10 20 30 40 50 0 10 20 30 40 50 k k 0.10 0.10 โ 0.08 0.08 โ โ โ 0.06 0.06 โ โ โ โ ฯ k ฯ k โ โ 0.04 โ 0.04 โ โ โ โ โ โ โ โ โ โ โ โ 0.02 0.02 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 0.00 0.00 0 10 20 30 40 50 0 10 20 30 40 50 k k Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 37 / 99
Part 1 LNRE models: intuition The Zipf-Mandelbrot law as a population model What is the right family of models for lexical frequency distributions? โฎ We have already seen that the Zipf-Mandelbrot law captures the distribution of observed frequencies very well Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 38 / 99
Part 1 LNRE models: intuition The Zipf-Mandelbrot law as a population model What is the right family of models for lexical frequency distributions? โฎ We have already seen that the Zipf-Mandelbrot law captures the distribution of observed frequencies very well โฎ Re-phrase the law for type probabilities: C ฯ i := ( i + b ) a โฎ Two free parameters: a > 1 and b โฅ 0 โฎ C is not a parameter but a normalization constant, needed to ensure that ๏ฟฝ i ฯ i = 1 โฎ This is the Zipf-Mandelbrot population model Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 38 / 99
Part 1 LNRE models: intuition The parameters of the Zipf-Mandelbrot model 0.10 0.10 โ a = 1.2 โ a = 2 0.08 0.08 b = 1.5 b = 10 โ 0.06 0.06 โ โ โ ฯ k ฯ k โ 0.04 0.04 โ โ โ โ โ โ โ โ 0.02 0.02 โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 0.00 0.00 0 10 20 30 40 50 0 10 20 30 40 50 k k 0.10 0.10 โ a = 2 a = 5 0.08 0.08 โ b = 15 b = 40 โ โ 0.06 0.06 โ โ โ โ ฯ k ฯ k โ โ 0.04 โ 0.04 โ โ โ โ โ โ โ โ โ โ โ โ 0.02 0.02 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 0.00 0.00 0 10 20 30 40 50 0 10 20 30 40 50 k k Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 39 / 99
Part 1 LNRE models: intuition The parameters of the Zipf-Mandelbrot model โ โ 5eโ02 5eโ02 โ โ โ a = 1.2 โ a = 2 โ โ โ โโโโโ โ b = 1.5 b = 10 โ โ โ โ โ โ โ โโโโ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 5eโ03 โ 5eโ03 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ ฯ k โ โ ฯ k โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 5eโ04 โ โ โ โ โ โ โ 5eโ04 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 1eโ04 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 1eโ04 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 1 2 5 10 20 50 100 1 2 5 10 20 50 100 k k โ โ 5eโ02 5eโ02 โ โ โ โ โ โโโโโ โ โ a = 2 a = 5 โ โ โ โโโโโ b = 15 โ b = 40 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 5eโ03 โ โ 5eโ03 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ ฯ k โ โ ฯ k โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 5eโ04 โ โ โ โ โ โ 5eโ04 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 1eโ04 โ โ โ โ โ โ โ โ โ โ โ โ 1eโ04 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 1 2 5 10 20 50 100 1 2 5 10 20 50 100 k k Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 40 / 99
Part 1 LNRE models: intuition The finite Zipf-Mandelbrot model Evert (2004) โฎ Zipf-Mandelbrot population model characterizes an infinite type population: there is no upper bound on i , and the type probabilities ฯ i can become arbitrarily small โฎ ฯ = 10 โ 6 (once every million words), ฯ = 10 โ 9 (once every billion words), ฯ = 10 โ 15 (once on the entire Internet), ฯ = 10 โ 100 (once in the universe?) Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 41 / 99
Part 1 LNRE models: intuition The finite Zipf-Mandelbrot model Evert (2004) โฎ Zipf-Mandelbrot population model characterizes an infinite type population: there is no upper bound on i , and the type probabilities ฯ i can become arbitrarily small โฎ ฯ = 10 โ 6 (once every million words), ฯ = 10 โ 9 (once every billion words), ฯ = 10 โ 15 (once on the entire Internet), ฯ = 10 โ 100 (once in the universe?) โฎ The finite Zipf-Mandelbrot model stops after first S types โฎ Population diversity S becomes a parameter of the model โ the finite Zipf-Mandelbrot model has 3 parameters Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 41 / 99
Part 1 LNRE models: intuition The finite Zipf-Mandelbrot model Evert (2004) โฎ Zipf-Mandelbrot population model characterizes an infinite type population: there is no upper bound on i , and the type probabilities ฯ i can become arbitrarily small โฎ ฯ = 10 โ 6 (once every million words), ฯ = 10 โ 9 (once every billion words), ฯ = 10 โ 15 (once on the entire Internet), ฯ = 10 โ 100 (once in the universe?) โฎ The finite Zipf-Mandelbrot model stops after first S types โฎ Population diversity S becomes a parameter of the model โ the finite Zipf-Mandelbrot model has 3 parameters Abbreviations: โฎ ZM for Zipf-Mandelbrot model โฎ fZM for finite Zipf-Mandelbrot model Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 41 / 99
Part 1 LNRE models: intuition Sampling from a population model Assume we believe that the population we are interested in can be described by a Zipf-Mandelbrot model: 0.05 5eโ02 a = 3 a = 3 โ โ 0.04 โ โ โ โ โโโโโ b = 50 b = 50 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 0.03 โ โ โ โ 5eโ03 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ ฯ k ฯ k โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 0.02 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 5eโ04 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 0.01 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 1eโ04 โ โ โ โ โ โ โ โ โ โ โ 0.00 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 0 10 20 30 40 50 1 2 5 10 20 50 100 k k Use computer simulation to generate random samples: โฎ Draw N tokens from the population such that in each step, type w i has probability ฯ i to be picked โฎ This allows us to make predictions for samples (= corpora) of arbitrary size N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 42 / 99
Part 1 LNRE models: intuition Sampling from a population model 1 42 34 23 108 18 48 18 1 . . . #1: Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 43 / 99
Part 1 LNRE models: intuition Sampling from a population model 1 42 34 23 108 18 48 18 1 . . . #1: time order room school town course area course time . . . Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 43 / 99
Part 1 LNRE models: intuition Sampling from a population model 1 42 34 23 108 18 48 18 1 . . . #1: time order room school town course area course time . . . #2: 286 28 23 36 3 4 7 4 8 . . . Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 43 / 99
Part 1 LNRE models: intuition Sampling from a population model 1 42 34 23 108 18 48 18 1 . . . #1: time order room school town course area course time . . . #2: 286 28 23 36 3 4 7 4 8 . . . 2 11 105 21 11 17 17 1 16 . . . #3: Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 43 / 99
Part 1 LNRE models: intuition Sampling from a population model 1 42 34 23 108 18 48 18 1 . . . #1: time order room school town course area course time . . . #2: 286 28 23 36 3 4 7 4 8 . . . 2 11 105 21 11 17 17 1 16 . . . #3: #4: 44 3 110 34 223 2 25 20 28 . . . #5: 24 81 54 11 8 61 1 31 35 . . . #6: 3 65 9 165 5 42 16 20 7 . . . #7: 10 21 11 60 164 54 18 16 203 . . . #8: 11 7 147 5 24 19 15 85 37 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 43 / 99
Part 1 LNRE models: intuition Samples: type frequency list & spectrum rank r f r type i m V m 1 37 6 1 83 2 36 1 2 22 3 33 3 3 20 4 31 7 4 12 5 31 10 5 10 6 30 5 6 5 7 28 12 7 5 8 27 2 8 3 9 24 4 9 3 10 24 16 10 3 . . 11 23 8 . . . . 12 22 14 . . . . . . . . . sample #1 Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 44 / 99
Part 1 LNRE models: intuition Samples: type frequency list & spectrum rank r f r type i m V m 1 39 2 1 76 2 34 3 2 27 3 30 5 3 17 4 29 10 4 10 5 28 8 5 6 6 26 1 6 5 7 25 13 7 7 8 24 7 8 3 9 23 6 10 4 10 23 11 11 2 . . 11 20 4 . . . . 12 19 17 . . . . . . . . . sample #2 Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 45 / 99
Part 1 LNRE models: intuition Random variation in type-frequency lists Sample #1 Sample #2 40 40 โ โ โ โ โ โโ 30 30 โ โ โ โ โ โ โ โ โโ โ โ โโ โ 20 โ 20 f r f r โ r โ f r โ โโ โ โโ โโโ โโโโโ โ โ โโโ โ โ โโ โ โโโโ โโโ โ โโ 10 10 โโโ โโโโ โโโ โโโ โโโ โโโโโ โโโโโโโ โโโโโ โโโโโ โโโโ 0 0 0 10 20 30 40 50 0 10 20 30 40 50 r r Sample #1 Sample #2 40 40 โ โ โ โ โ โ โ 30 30 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ 20 20 f k f k โ โ โ โ i โ f i โ โ โ โ โ โ โ โโ โโ โ โ โโ โ โ โ โ โ โ โ โโ โ โ โ 10 โ 10 โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โโ โ โ โ โ โ โโ โ โ โ โ โ โ โ โ โ โ โโ โ โ โ โ 0 0 0 10 20 30 40 50 0 10 20 30 40 50 k k Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 46 / 99
Part 1 LNRE models: intuition Random variation: frequency spectrum Sample #1 100 80 60 V m 40 20 0 m Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 47 / 99
Part 1 LNRE models: intuition Random variation: frequency spectrum Sample #2 100 80 60 V m 40 20 0 m Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 47 / 99
Part 1 LNRE models: intuition Random variation: frequency spectrum Sample #3 100 80 60 V m 40 20 0 m Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 47 / 99
Part 1 LNRE models: intuition Random variation: frequency spectrum Sample #4 100 80 60 V m 40 20 0 m Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 47 / 99
Part 1 LNRE models: intuition Random variation: vocabulary growth curve Sample #1 200 150 V ( N ) V 1 ( N ) 100 50 0 0 200 400 600 800 1000 N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 48 / 99
Part 1 LNRE models: intuition Random variation: vocabulary growth curve Sample #2 200 150 V ( N ) V 1 ( N ) 100 50 0 0 200 400 600 800 1000 N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 48 / 99
Part 1 LNRE models: intuition Random variation: vocabulary growth curve Sample #3 200 150 V ( N ) V 1 ( N ) 100 50 0 0 200 400 600 800 1000 N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 48 / 99
Part 1 LNRE models: intuition Random variation: vocabulary growth curve Sample #4 200 150 V ( N ) V 1 ( N ) 100 50 0 0 200 400 600 800 1000 N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 48 / 99
Part 1 LNRE models: intuition Expected values โฎ There is no reason why we should choose a particular sample to compare to the real data or make a prediction โ each one is equally likely or unlikely โฎ Take the average over a large number of samples, called expected value or expectation in statistics ๏ฟฝ and E ๏ฟฝ V ( N ) ๏ฟฝ V m ( N ) ๏ฟฝ โฎ Notation: E โฎ indicates that we are referring to expected values for a sample of size N โฎ rather than to the specific values V and V m observed in a particular sample or a real-world data set โฎ Expected values can be calculated efficiently without generating thousands of random samples Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 49 / 99
Part 1 LNRE models: intuition The expected frequency spectrum Sample #1 100 V m E [ [ V m ] 80 60 V m E [ V m ] 40 20 0 m Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 50 / 99
Part 1 LNRE models: intuition The expected frequency spectrum Sample #2 100 V m E [ [ V m ] 80 60 V m E [ V m ] 40 20 0 m Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 50 / 99
Part 1 LNRE models: intuition The expected frequency spectrum Sample #3 100 V m E [ [ V m ] 80 60 V m E [ V m ] 40 20 0 m Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 50 / 99
Part 1 LNRE models: intuition The expected frequency spectrum Sample #4 100 V m E [ [ V m ] 80 60 V m E [ V m ] 40 20 0 m Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 50 / 99
Part 1 LNRE models: intuition The expected vocabulary growth curve Sample #1 Sample #1 200 200 150 150 E [ V 1 ( N )] E [ V ( N )] 100 100 50 50 V ( N ) V 1 ( N ) E [ V ( N )] E [ V 1 ( N )] 0 0 0 200 400 600 800 1000 0 200 400 600 800 1000 N N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 51 / 99
Part 1 LNRE models: intuition Prediction intervals for the expected VGC Sample #1 Sample #1 200 200 150 150 E [ V 1 ( N )] E [ V ( N )] 100 100 50 50 V ( N ) V 1 ( N ) E [ V ( N )] E [ V 1 ( N )] 0 0 0 200 400 600 800 1000 0 200 400 600 800 1000 N N โConfidence intervalsโ indicate predicted sampling distribution: โ for 95% of samples generated by the LNRE model, VGC will fall within the range delimited by the thin red lines Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 52 / 99
Part 1 LNRE models: intuition Parameter estimation by trial & error 25000 a = 1.5 , b = 7.5 50000 a = 1.5 , b = = 7.5 observed ZM model 20000 40000 15000 30000 V ( N ) E [ V ( N )] V m E [ V m ] 10000 20000 10000 5000 observed ZM model 0 0 0e+00 2e+05 4e+05 6e+05 8e+05 1e+06 m N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 53 / 99
Part 1 LNRE models: intuition Parameter estimation by trial & error 25000 a = 1.3 , b = 7.5 50000 a = 1.3 , b = = 7.5 observed ZM model 20000 40000 15000 30000 V ( N ) E [ V ( N )] V m E [ V m ] 10000 20000 10000 5000 observed ZM model 0 0 0e+00 2e+05 4e+05 6e+05 8e+05 1e+06 m N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 53 / 99
Part 1 LNRE models: intuition Parameter estimation by trial & error 25000 a = 1.3 , b = 0.2 50000 a = 1.3 , b = = 0.2 observed ZM model 20000 40000 15000 30000 V ( N ) E [ V ( N )] V m E [ V m ] 10000 20000 10000 5000 observed ZM model 0 0 0e+00 2e+05 4e+05 6e+05 8e+05 1e+06 m N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 53 / 99
Part 1 LNRE models: intuition Parameter estimation by trial & error 25000 a = 1.5 , b = 7.5 50000 a = 1.5 , b = = 7.5 observed ZM model 20000 40000 15000 30000 V ( N ) E [ V ( N )] V m E [ V m ] 10000 20000 10000 5000 observed ZM model 0 0 0e+00 2e+05 4e+05 6e+05 8e+05 1e+06 m N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 53 / 99
Part 1 LNRE models: intuition Parameter estimation by trial & error 25000 a = 1.7 , b = 7.5 50000 a = 1.7 , b = = 7.5 observed ZM model 20000 40000 15000 30000 V ( N ) E [ V ( N )] V m E [ V m ] 10000 20000 10000 5000 observed ZM model 0 0 0e+00 2e+05 4e+05 6e+05 8e+05 1e+06 m N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 53 / 99
Part 1 LNRE models: intuition Parameter estimation by trial & error 25000 a = 1.7 , b = 80 50000 a = 1.7 , b = = 80 observed ZM model 20000 40000 15000 30000 V ( N ) E [ V ( N )] V m E [ V m ] 10000 20000 10000 5000 observed ZM model 0 0 0e+00 2e+05 4e+05 6e+05 8e+05 1e+06 m N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 53 / 99
Part 1 LNRE models: intuition Parameter estimation by trial & error 25000 a = 2 , b = 550 50000 a = 2 , b = = 550 observed ZM model 20000 40000 15000 30000 V ( N ) E [ V ( N )] V m E [ V m ] 10000 20000 10000 5000 observed ZM model 0 0 0e+00 2e+05 4e+05 6e+05 8e+05 1e+06 m N Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 53 / 99
Part 1 LNRE models: intuition Automatic parameter estimation 25000 a = 2.39 , b = 1968.49 50000 a = 2.39 , b = = 1968.49 observed expected 20000 40000 15000 30000 V ( N ) E [ V ( N )] V m E [ V m ] 10000 20000 10000 5000 observed expected 0 0 0e+00 2e+05 4e+05 6e+05 8e+05 1e+06 m N โฎ By trial & error we found a = 2 . 0 and b = 550 โฎ Automatic estimation procedure: a = 2 . 39 and b = 1968 Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 54 / 99
Part 1 LNRE models: mathematics Outline Part 1 Motivation Descriptive statistics & notation Some examples (zipfR) LNRE models: intuition LNRE models: mathematics Part 2 Applications & examples (zipfR) Limitations Non-randomness Conclusion & outlook Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 55 / 99
Part 1 LNRE models: mathematics The sampling model โฎ Draw random sample of N tokens from LNRE population โฎ Sufficient statistic: set of type frequencies { f i } โฎ because tokens of random sample have no ordering โฎ Joint multinomial distribution of { f i } : N ! k 1 ! ยท ยท ยท k S ! ฯ k 1 1 ยท ยท ยท ฯ k S Pr ( { f i = k i } | N ) = S Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 56 / 99
Part 1 LNRE models: mathematics The sampling model โฎ Draw random sample of N tokens from LNRE population โฎ Sufficient statistic: set of type frequencies { f i } โฎ because tokens of random sample have no ordering โฎ Joint multinomial distribution of { f i } : N ! k 1 ! ยท ยท ยท k S ! ฯ k 1 1 ยท ยท ยท ฯ k S Pr ( { f i = k i } | N ) = S โฎ Approximation: do not condition on fixed sample size N โฎ N is now the average (expected) sample size โฎ Random variables f i have independent Poisson distributions: Pr ( f i = k i ) = e โ N ฯ i ( N ฯ i ) k i k i ! Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 56 / 99
Part 1 LNRE models: mathematics Frequency spectrum โฎ Key problem: we cannot determine f i in observed sample โฎ becasue we donโt know which type w i is โฎ recall that population ranking f i ๏ฟฝ = Zipf ranking f r โฎ Use spectrum { V m } and sample size V as statistics โฎ contains all information we have about observed sample Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 57 / 99
Part 1 LNRE models: mathematics Frequency spectrum โฎ Key problem: we cannot determine f i in observed sample โฎ becasue we donโt know which type w i is โฎ recall that population ranking f i ๏ฟฝ = Zipf ranking f r โฎ Use spectrum { V m } and sample size V as statistics โฎ contains all information we have about observed sample โฎ Can be expressed in terms of indicator variables ๏ฟฝ 1 f i = m I [ f i = m ] = 0 otherwise Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 57 / 99
Part 1 LNRE models: mathematics Frequency spectrum โฎ Key problem: we cannot determine f i in observed sample โฎ becasue we donโt know which type w i is โฎ recall that population ranking f i ๏ฟฝ = Zipf ranking f r โฎ Use spectrum { V m } and sample size V as statistics โฎ contains all information we have about observed sample โฎ Can be expressed in terms of indicator variables ๏ฟฝ 1 f i = m I [ f i = m ] = 0 otherwise S ๏ฟฝ V m = I [ f i = m ] i =1 Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 57 / 99
Part 1 LNRE models: mathematics Frequency spectrum โฎ Key problem: we cannot determine f i in observed sample โฎ becasue we donโt know which type w i is โฎ recall that population ranking f i ๏ฟฝ = Zipf ranking f r โฎ Use spectrum { V m } and sample size V as statistics โฎ contains all information we have about observed sample โฎ Can be expressed in terms of indicator variables ๏ฟฝ 1 f i = m I [ f i = m ] = 0 otherwise S ๏ฟฝ V m = I [ f i = m ] i =1 S S ๏ฟฝ ๏ฟฝ ๏ฟฝ 1 โ I [ f i =0] ๏ฟฝ V = I [ f i > 0] = i =1 i =1 Stefan Evert T1: Zipfโs Law 7 May 2018 | CC-by-sa 57 / 99
Recommend
More recommend