<jupyter_start><jupyter_text>Poisson Distribution - Errors in Text> This document is written in *R*.>> ***GitHub***: https://github.com/czs108  Background> In a certain long document there is an *average* of **0.5** typographical errors per **100** words of text.  Question A> What is the *mean* number of words between errors? \begin{equation}Mean = \frac{1}{0.5} \times 100 = 200\end{equation}  Question B> What is the probability of finding **4** errors in a text of length **500** words? \begin{equation}\lambda = 0.5 \times \frac{500}{100} = 2.5\end{equation}\begin{equation}\begin{split}P(X = 4) &= \frac{e^{-\lambda} \cdot {\lambda}^{4}}{4!} \\    &= \frac{e^{-2.5} \cdot {2.5}^{4}}{4!}\end{split}\end{equation} Use the `dpois` function.<jupyter_code>dpois(x=4, lambda=2.5)<jupyter_output><empty_output><jupyter_text>Question C> What is the probability of there being *at least* **300** words before the *1st* error? \begin{equation}\lambda = 0.5 \times \frac{300}{100} = 1.5\end{equation}\begin{equation}\begin{split}P(X = 0) &= \frac{e^{-\lambda} \cdot {\lambda}^{0}}{0!} \\    &= e^{-1.5}\end{split}\end{equation}<jupyter_code>dpois(x=0, lambda=1.5)<jupyter_output><empty_output><jupyter_text>Use the `exp` function.<jupyter_code>exp(-1.5)<jupyter_output><empty_output><jupyter_text>Question D> What is the *minimum* number of words in which the probability of finding an error is *at least* **90%**? We know that\begin{equation}P(X = 1) \geq 0.9\end{equation}So\begin{equation}P(X = 0) < 0.1\end{equation}Assume $n$ is the number of words.\begin{equation}\lambda = 0.5 \times \frac{n}{100}\end{equation}\begin{equation}\begin{split}P(X = 0) &= \frac{e^{-\lambda} \cdot {\lambda}^{0}}{0!} \\    &= e^{-\lambda} \\    &< 0.1\end{split}\end{equation}Then we get\begin{equation}\ln 0.1 = -2.3\end{equation}<jupyter_code>log(0.1)<jupyter_output><empty_output><jupyter_text>When $-\lambda < -2.3$, $P(X = 0) < 0.1$.So $\lambda > 2.3$\begin{equation}n = 200 \times \lambda > 460\end{equation}  Question E> How many words would there be on a page, if the probability of **0** errors on a page was **20%**? Assume $n$ is the number of words on a page. \begin{equation}\lambda = 0.5 \times \frac{n}{100}\end{equation}\begin{equation}\begin{split}P(X = 0) &= \frac{e^{-\lambda} \cdot {\lambda}^{0}}{0!} \\    &= e^{-\lambda} \\    &= 0.2\end{split}\end{equation}Then we get\begin{align}\ln 0.2 = -\lambda \\\lambda = 1.609\end{align}<jupyter_code>-log(0.2)<jupyter_output><empty_output><jupyter_text>\begin{equation}n = 200 \times \lambda = 322\end{equation}  Question F> What is the probability of there being *at least* **2000** words before there are **10** errors? \begin{equation}\lambda = 0.5 \times \frac{2000}{100} = 10\end{equation}\begin{equation}\begin{split}P(X \leq 9) &= \sum_{i=0}^{9} P(X = i) \\    &= \sum_{i=0}^{9} \frac{e^{-10} \cdot {10}^{i}}{i!}\end{split}\end{equation}<jupyter_code>sum(dpois(x=c(0:9), lambda=10))<jupyter_output><empty_output><jupyter_text>Or use the `ppois` function.<jupyter_code>ppois(q=9, lambda=10)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20826553856166613, 'fraction_numerical': 0.053368044256426946, 'mean_word_length': 5.099206349206349, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 41, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '514287', 'license': 'MIT', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1122, 'n_words': 260, 'path': 'exercises/Poisson Distribution - Errors in Text.ipynb', 'repo_name': 'czs108/Probability-Theory-Exercises', 'size': '3073'}