Chapterبەش 6 · Lectureوانە 6.1
Probability in Computing: Speech, Predictive Text and Riskبەکارهێنانی ئەگەر لە بواری کۆمپیوتەردا: ئاخاوتن، پێشبینیی دەق و مەترسی
How computers use probability: speech recognition picks the most probable text (Bayes, hidden Markov models, today's neural networks), predictive text ranks next words by conditional probability, six fields of computer science that depend on probability, earthquake hazard as probabilities of shaking rather than predictions, and pseudo-random numbers in Python: a Monte Carlo estimate of π, and why secrets, not random, protects passwords and codes.
چۆن بەکار دەهێنن: گونجاوترین دەق هەڵدەبژێرێت (، و ئەمڕۆ)، وشەی دواتر بە ڕیز دەکات، شەش بواری زانستی کە پشت بە دەبەستن، مەترسیی بوومەلەرزە وەک لەرزین نەک پێشبینی، هەروەها لە Pythonـدا: خەمڵاندنی π بە و بۆچی secrets، نەک random، و کۆدەکان دەپارێزێت.
What you will learnچی فێر دەبیت
- Explain how speech recognition and predictive text choose the most probable text or word.
- Estimate a next-word probability from counts and update it when a letter is typed.
- Name six fields of computer science that use probability, with an example of each.
- Interpret a seismic hazard curve and turn "2% in 50 years" into a yearly probability.
- Use pseudo-random numbers for a Monte Carlo estimate and explain why secrets must be used for security.
- ڕوون بکەیتەوە و چۆن گونجاوترین دەق یان وشە هەڵدەبژێرن.
- وشەی دواتر لە ژمارەکانەوە بخەمڵێنیت و کاتێک پیتێک دەنووسرێت نوێی بکەیتەوە.
- شەش بواری زانستی ناو بهێنیت کە بەکار دەهێنن، بە نموونەیەک بۆ هەر یەکێک.
- لێک بدەیتەوە و «دوو لە سەد لە پەنجا ساڵدا» بکەیت بە ساڵانە.
- بۆ خەمڵاندنێکی بەکار بهێنیت و ڕوون بکەیتەوە بۆچی دەبێت
secretsبۆ بەکار بهێنرێت.
Guessing, weighing risk and using chanceمەزەندەکردن، هەڵسەنگاندنی مەترسی و بەکارهێنانی ڕێکەوت
You have learned to count outcomes, to combine events, to update a probability with new information and to describe random variables. This last chapter shows the same tools at work inside computers. Probability enters computing in three main ways:
فێربوویت بژمێریت، پێکەوە ببەستیت، بە زانیاریی نوێ نوێ بکەیتەوە و وەسف بکەیت. ئەم بەشە کۆتاییە هەمان ئامرازەکان لە ناو لە کاردا نیشان دەدات. بە سێ ڕێگای سەرەکی دێتە ناو :
- Choosing the most probable answer when the input is unclear: what did the speaker say, which word will you type next?
- Measuring risk when the future cannot be known: how strongly may the ground shake here in the next 50 years?
- Using randomness on purpose: simulations, games, fast algorithms and secret keys.
- هەڵبژاردنی گونجاوترین وەڵام کاتێک ڕوون نییە: قسەکەر چی گوت، وشەی داهاتووت چییە؟
- پێوانی کاتێک داهاتوو نازانرێت: لە پەنجا ساڵی داهاتوودا زەوی لێرە چەند بەهێز دەلەرزێت؟
- بەکارهێنانی ڕێکەوت بە مەبەست: ، یاری، خێرا و .
Each screen links back to the lesson where the tool was taught, so you can look again when you need to.
هەر پەڕەیەک بۆ ئەو وانەیە هەیە کە ئامرازەکەی تێدا فێرکرا، بۆ ئەوەی هەر کاتێک پێویست بوو بگەڕێیتەوە سەری.
Speech recognition: the most probable textناسینەوەی ئاخاوتن: گونجاوترین دەق
When you dictate a message or talk to a voice assistant, speech recognition software turns your speech into text or commands. The microphone gives it only a sound signal, and the same word sounds different with every voice, accent, speed and background noise. So the software can never be sure. It makes the best guess: the text with the highest probability, given the sound.
کاتێک نامەیەک بە دەنگ دەنووسیت یان قسە لەگەڵ دەکەیت، قسەکانت دەکات بە دەق یان فەرمان. تەنها دەنگی دەداتێ. هەمان وشەش بە هەر دەنگ، شێوەزار، خێرایی و ژاوەژاوێکی دەوروبەر جیاواز دەبیسترێت. بۆیە هەرگیز دڵنیا نابێت. باشترین مەزەندە دەکات: ئەو دەقەی کە بە پێی دەنگەکە بەرزترین هەیە.
It works in steps. The signal is cut into tiny pieces called frames, one every 10 milliseconds. Statistical models estimate, for each piece, the probability of each possible small unit of speech: a phoneme (one of the small sounds that tell words apart, like the /k/ of cat) or a whole word. Then the system compares possible words and phrases, computes the probability of each, and outputs the most probable one.
بە هەنگاو کار دەکات. دەبڕدرێت بۆ پارچەی زۆر بچووک کە پێیان دەگوترێت پارچە، هەر دە میلیچرکە پارچەیەک. مۆدێلە ئامارییەکان بۆ هەر پارچەیەک هەر یەکەیەکی بچووکی ئاخاوتن دەخەمڵێنن: (یەکێک لەو دەنگە بچووکانەی وشەکان لە یەک جیا دەکەنەوە، وەک /k/ لە cat) یان وشەیەکی تەواو. پاشان سیستەمەکە وشە و دەستەواژە گونجاوەکان بەراورد دەکات، هەر یەکێکیان حیساب دەکات و گونجاوترینیان دەکاتە .
Speech recognition: the most probable textناسینەوەی ئاخاوتن: گونجاوترین دەق
Two probabilities, multiplied: Bayes at workدوو ئەگەر، لێکدراو: سەلمێنراوی بەیز لە کاردا
A recogniser asks two questions about every possible text: does it match the sound? and is it something people actually say? The acoustic model answers the first, the language model the second. Bayes' theorem joins them:
سیستەمی ناسینەوە دوو پرسیار دەربارەی هەر دەقێکی گونجاو دەکات: ئایا لەگەڵ دەنگەکە دەگونجێت؟ و ئایا خەڵک بەڕاستی شتی وا دەڵێن؟ وەڵامی یەکەم دەداتەوە و وەڵامی دووەم. هەردووکیان پێکەوە دەبەستێت:
Read as "the text that makes this largest". By Bayes' theorem, ; the bottom is the same for every candidate, so it cannot change which one wins and is left out.
بەم شێوەیە بخوێنەوە: «ئەو دەقەی کە ئەمە گەورەترین دەکات». بەپێی سەلمێنراوی بەیز، ؛ بەشی خوارەوە، ، بۆ هەموو دەقە گونجاوەکان وەک یەکە، بۆیە ناتوانێت بگۆڕێت کامیان دەباتەوە و لادەبرێت.
| Possible textدەقی گونجاو | Matches the sound گونجان لەگەڵ دەنگ | Common in language باو لە زماندا | Productلێکدان |
|---|---|---|---|
an ice cream | |||
an I scream |
an I scream matches the sound a little better (0.32 against 0.30), but people almost never write it. The product decides: , so an ice cream is 375 times more probable and becomes the output.
an I scream کەمێک باشتر لەگەڵ دەنگەکە دەگونجێت (0.32 بەرامبەر 0.30)، بەڵام خەڵک بە دەگمەن دەینووسن. لێکدانەکە بڕیار دەدات: ، کەواتە an ice cream جار زیاترە و دەبێتە .
Speech recognition: the most probable textناسینەوەی ئاخاوتن: گونجاوترین دەق
Hidden Markov models: the classic methodمۆدێلی شاراوەی مارکۆڤ: ڕێگا کلاسیکییەکە
From the 1980s to the 2000s most recognisers used a hidden Markov model (HMM). It describes speech as a chain of states, one for each sound or word. The states are hidden: the computer never hears "/k/" directly; it only receives the signal. The model holds two kinds of probabilities:
لە ساڵانی هەشتاکانەوە تا ساڵانی دووهەزارەکان زۆربەی سیستەمەکانی ناسینەوە (HMM)یان بەکار دەهێنا. ئاخاوتن وەک زنجیرەیەک دۆخ وەسف دەکات، بۆ هەر دەنگێک یان وشەیەک دۆخێک. دۆخەکان شاراوەن: هەرگیز ڕاستەوخۆ «/k/» نابیستێت؛ تەنها وەردەگرێت. دوو جۆر لەخۆ دەگرێت:
- Transition probabilities: from one state, how likely is the next one? Stay in /k/, or move on to /æ/?
- Emission probabilities: in a given state, how likely is each piece of sound that the microphone records?
- گواستنەوە: لە دۆخێکەوە، دۆخی دواتر چەند هەیە؟ لە /k/دا بمێنێتەوە یان بچێتە سەر /æ/؟
- دەرچوون: لە دۆخێکی دیاریکراودا، هەر پارچەیەکی ئەو دەنگەی تۆماری دەکات چەند هەیە؟
The HMM cuts the signal into frames and computes the probability that each frame belongs to each sound unit. To recognise a word, the system compares the input with the HMMs of all possible words or phrases, computes the probability of each, and outputs the one with the highest probability. A path through the states is a chain of steps, so its probability is a product of probabilities. "Markov" means the next state depends only on the current one, an idea named after the Russian mathematician Andrey Markov.
دەبڕێت بۆ پارچە و ئەوە حیساب دەکات کە هەر پارچەیەک سەر بە هەر یەکەیەکی دەنگی بێت. بۆ ناسینەوەی وشەیەک، سیستەمەکە لەگەڵ هەموو وشە یان دەستەواژە گونجاوەکان بەراورد دەکات، هەر یەکێکیان حیساب دەکات و ئەوەیان دەکاتە کە بەرزترین هەیە. ڕێڕەوێک بە ناو دۆخەکاندا زنجیرەیەک هەنگاوە، بۆیە لێکدانی چەند ئەگەرێکە. «مارکۆڤ» واتە دۆخی دواتر تەنها پشت بە دۆخی ئێستا دەبەستێت؛ ئەم بیرۆکەیە ناوی بیرکاریزانی ڕووسی ئەندرێی مارکۆڤی لێنراوە.
A hidden Markov model: hidden states you cannot see, transition and emission probabilities, and finding the most likely hidden sequence.
: دۆخە شاراوەکان کە نایانبینیت، گواستنەوە و دەرچوون، هەروەها دۆزینەوەی گونجاوترین زنجیرەی دۆخە شاراوەکان.
Whole video: Markov chains recap (0:37), hidden states (1:55), the probability of a scenario (3:11), the most likely hidden sequence (5:19).
هەموو ڤیدیۆکە: پێداچوونەوەی زنجیرەی مارکۆڤ (0:37)، دۆخە شاراوەکان (1:55)، سیناریۆیەک (3:11)، گونجاوترین زنجیرەی شاراوە (5:19).
Speech recognition: the most probable textناسینەوەی ئاخاوتن: گونجاوترین دەق
Today: neural networks, still probabilitiesئەمڕۆ: تۆڕە دەمارییەکان، بەڵام هەر ئەگەر
The main point of the note still holds. A neural recogniser also ends with probabilities: for every short piece of sound it gives a probability to each possible letter, word piece or word, and the system outputs the most probable text. It is still a best guess, which is why dictation sometimes writes a word that sounds right but is wrong. How neural networks learn is explained in Neural networks, deep learning and generative AI.
خاڵی سەرەکیی تێبینییەکە هێشتا ڕاستە. بۆ ناسینەوەش لە کۆتاییدا دەدات: بۆ هەر پارچەیەکی کورتی دەنگ دەداتە هەر پیت، پارچە وشە یان وشەیەکی گونجاو و سیستەمەکە گونجاوترین دەق دەکاتە . هێشتا باشترین مەزەندەیە، بۆیە نووسینی دەنگی هەندێک جار وشەیەک دەنووسێت کە دەنگی دروستە بەڵام خۆی هەڵەیە. چۆنیەتی فێربوونی لە تۆڕە دەمارییەکان، فێربوونی قووڵ و ژیریی دەستکردی بەرهەمهێنەر ڕوون کراوەتەوە.
The course essay's examples of voice assistants, and why one of them was retired, are discussed in What is statistics?.
نموونەکانی نامیلکەی خولەکە بۆ و هۆی وەستاندنی یەکێکیان لە ئامار چییە؟ باس کراون.
Predictive text: guessing your next wordپێشبینیی دەق: مەزەندەکردنی وشەی داهاتووت
Smartphones use probability every time you type. The predictive text feature reads what you have typed so far and suggests the next word, choosing the words with the highest probability of coming next. Here is the owner's own phone: after typing Th, the keyboard offers Th (the letters as typed), The and Thanks.
هەر جارێک دەنووسیت بەکار دەهێنن. تایبەتمەندیی ئەوە دەخوێنێتەوە کە تا ئێستا نووسیوتە و وشەی دواتر پێشنیار دەکات؛ ئەو وشانە هەڵدەبژێرێت کە بەرزترین هەیە دواتر بێن. ئەمە مۆبایلی خاوەنی سایتەکەیە: دوای نووسینی Th، Th (پیتەکان وەک نووسراون)، The و Thanks پێشنیار دەکات.
The course note gives a whole-word example. If you have typed I am going to the, the program computes the probability of every word that could follow, using its language model. If store is the word that most often follows in that context, store is suggested first.
تێبینییەکەی خولەکە نموونەیەکی وشەی تەواو دەهێنێتەوە. گەر ئەم وشانەت نووسیبێت: I am going to the، بە خۆی هەموو ئەو وشانە حیساب دەکات کە دەکرێت دواتر بێن. گەر store ئەو وشەیە بێت کە لەو دۆخەدا زۆرترین جار دواتر دێت، یەکەم جار store پێشنیار دەکرێت.
Predictive text: guessing your next wordپێشبینیی دەق: مەزەندەکردنی وشەی داهاتووت
Counting what comes nextژماردنی ئەوەی دواتر دێت
The probability that store comes next is a conditional probability: the probability of a word, given the words already typed. A simple way to estimate it is to count. Suppose that in a large collection of messages the words I am going to the appear 200 times, and 70 of those times the next word is store:
ئەوەی store دواتر بێت ئەگەرێکی مەرجدارە: وشەیەک، بە مەرجی ئەو وشانەی پێشتر نووسراون. ڕێگایەکی سادە بۆ خەمڵاندنی ژماردنە. وا دابنێ لە کۆمەڵێکی گەورەی نامەدا وشەکانی I am going to the دووسەد جار هاتوون و لە حەفتا جاریاندا وشەی دواتر store بووە:
Count how often the words come together, divide by how often the beginning appears: a relative frequency used as an estimate.
بژمێرە وشەکان چەند جار پێکەوە دێن و دابەشی بکە بەسەر ژمارەی هاتنی سەرەتاکەدا: دووبارەبوونەوەی ڕێژەیی وەک خەمڵاندن.
The keyboard shows the three most probable words: store, market, university. All possible next words together have probability 1: the three shown cover 0.75 and the dashed bar holds the other 0.25.
سێ وشەی گونجاوتر پیشان دەدات: store، market، university. هەموو وشە گونجاوەکانی دواتر پێکەوە 1ـە: ئەو سێیەی پیشان دراون 0.75 دەگرنەوە و ستوونە پچڕپچڕەکە 0.25ـەکەی تر هەڵدەگرێت.
Predictive text: guessing your next wordپێشبینیی دەق: مەزەندەکردنی وشەی داهاتووت
Each letter you type changes the listهەر پیتێک دەینووسیت لیستەکە دەگۆڕێت
While you type a word, the keyboard keeps only the words that start with your letters and shares the probability among them. Suppose these are the counts of first words that start with T in a collection of messages: The 120, Thanks 60, This 50, To 40, That 40, Today 35, They 30, Tomorrow 30, There 25, Thank 15, Thursday 5 (450 in all).
کاتێک وشەیەک دەنووسیت، تەنها ئەو وشانە دەهێڵێتەوە کە بە پیتەکانی تۆ دەست پێ دەکەن و لە نێوانیاندا دابەش دەکات. وا دابنێ ئەمانە ژمارەی ئەو یەکەم وشانەن کە بە T دەست پێ دەکەن لە کۆمەڵێک نامەدا: The 120، Thanks 60، This 50، To 40، That 40، Today 35، They 30، Tomorrow 30، There 25، Thank 15، Thursday 5 (کۆی گشتی 450).


After Th, only 8 words remain, with 345 counts together, so . After Than, only Thanks (60) and Thank (15) fit: . Every new letter makes the sample space smaller, exactly as in conditional probability. The owner's screenshot shows The and Thanks as the top suggestions after Th, the same two that lead here.
دوای Th تەنها هەشت وشە دەمێننەوە کە پێکەوە 345 جار هاتوون، بۆیە . دوای Than تەنها Thanks (60) و Thank (15) دەگونجێن: . هەر پیتێکی نوێ بۆشایی نموونەکە بچووکتر دەکاتەوە، ڕێک وەک لە . خاوەنی سایتەکە دوای Th وشەکانی The و Thanks وەک باشترین پێشنیار پیشان دەدات، هەمان ئەو دوانەی لێرەدا لە پێشن.
Predictive text: guessing your next wordپێشبینیی دەق: مەزەندەکردنی وشەی داهاتووت
Language models, small and largeمۆدێلەکانی زمان، بچووک و گەورە
A model that gives the probability of the next word (or of a whole sentence) from the words before it. Large ones are .
مۆدێلێکە کە ئەگەری وشەی دواتر (یان هەموو ڕستەیەک) لە وشەکانی پێشووەوە دەدات. گەورەکانیان .
The course note adds that a language model is a kind of AI made to work with natural language and to write text that sounds human. The table of next-word probabilities above is a very small language model.
تێبینییەکەی خولەکە ئەوەش دەڵێت کە جۆرێکە لە بۆ کارکردن لەگەڵ زمانی سروشتی و نووسینی دەقێک کە وەک هی مرۆڤ دەچێت. خشتەی وشەی دواتر لە سەرەوە زۆر بچووکە.
The probability of a whole sentence is built word by word: each word's probability, given the words before it, multiplied together. This is the multiplication rule written with product notation:
ڕستەیەکی تەواو وشە بە وشە دروست دەکرێت: هەر وشەیەک، بە مەرجی وشەکانی پێشووی، هەموویان لێکدەدرێن. ئەمە هەمان یاسای لێکدانی ئەگەرە کە بە نیشانەی پی نووسراوە:
from collections import Counter
text = """i am going to the store . we are going to the market .
i am going to the store . they are going to the university .
i am going to the store now . you are going to the market ."""
words = text.split()
# count the words that come straight after "the"
after_the = Counter(words[i + 1] for i in range(len(words) - 1) if words[i] == "the")
total = sum(after_the.values())
for word, count in after_the.most_common():
print(f"P({word} | the) = {count}/{total} = {count / total:.2f}")P(store | the) = 3/6 = 0.50 P(market | the) = 2/6 = 0.33 P(university | the) = 1/6 = 0.17
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 3-5
Here the text is typed into the program. A real model reads millions of words from files: reading a file word by word is taught in Words, numbers and CSV tables.
لێرەدا دەقەکە لە ناو نووسراوە. ڕاستەقینە ملیۆنان وشە لە دەخوێنێتەوە: خوێندنەوەی وشە بە وشە لە وشە، ژمارە و خشتەی CSV فێر دەکرێت.
- Lineدێڕی 9
Countercounts each word that comes straight after "the".Counterهەر وشەیەک دەژمێرێت کە ڕاستەوخۆ دوای «the» دێت.- Lineدێڕی 11-12
Each count divided by the total is an estimated conditional probability.
هەر ژمارەیەک دابەش بە کۆکە خەمڵێنراوە.
Real keyboards learn from far more text, and newer ones use neural networks: Apple's 2023 keyboard update, for example, uses a transformer language model for word prediction. Large language models, the engines of chatbots, are trained on huge amounts of text for one job: predict the next word (or piece of a word). They give probabilities, not certain facts, which is why a chatbot can sound sure and still be wrong. More in Neural networks, deep learning and generative AI and Natural language processing in your pocket.
ڕاستەقینە لە دەقێکی زۆر زیاتر فێر دەبن و نوێترەکانیان بەکار دەهێنن: بۆ نموونە نوێکردنەوەی Apple لە 2023ـدا بۆ پێشبینیی وشە بەکار دەهێنێت. ، کە بزوێنەری ، لەسەر بڕێکی زۆر زۆری دەق بۆ یەک کار ڕاهێنراون: پێشبینیی وشەی دواتر (یان پارچەیەکی وشە). ئەوان دەدەن، نەک ڕاستیی دڵنیا؛ بۆیە دەکرێت دڵنیا دیار بێت و هێشتا هەڵە بێت. زیاتر لە تۆڕە دەمارییەکان، فێربوونی قووڵ و ژیریی دەستکردی بەرهەمهێنەر و چارەسەرکردنی زمانی سروشتی لە گیرفانتدا.
See how a modern AI chatbot writes its answer by predicting the next word again and again.
ببینە نوێی چۆن وەڵامەکەی دەنووسێت: جار لە دوای جار پێشبینیی وشەی داهاتوو دەکات.
Whole video (8 minutes): next-word probabilities, training, and transformers, made for the Computer History Museum.
هەموو ڤیدیۆکە (8 خولەک): وشەی داهاتوو، ڕاهێنان و ؛ بۆ Computer History Museum دروست کراوە.
Probability across computer scienceبەکارهێنانی ئەگەر لە سەرانسەری زانستی کۆمپیوتەردا
The course notes list six fields of computer science where probability is a working tool. The tables keep each field's job and add one example you already know or will meet soon. Here are the first three; the other three come after a closer look at cryptography.
تێبینییەکانی خولەکە شەش بواری زانستی دەژمێرن کە تێیاندا ئامرازێکی کارە. خشتەکان کاری هەر بوارێک دەهێڵنەوە و نموونەیەک زیاد دەکەن کە پێشتر دەیناسیت یان بەم زووانە دەیبینیت. ئەمە سێ بواری یەکەمن؛ سێیەکەی تر دوای سەیرکردنێکی وردتری دێن.
| Fieldبوار | What probability does thereڕۆڵی لەو بوارەدا | Exampleنموونە |
|---|---|---|
| Machine learningبواری | Models uncertainty and learns from incomplete or noisy data (how a model learns from examples), for example with Bayesian networks and hidden Markov models.نادڵنیایی مۆدێل دەکات و لە ناتەواو یان ژاوەژاویدار فێر دەبێت (فێربوونی ئامێر چۆن لە نموونەکانەوە فێر دەبێت)، بۆ نموونە بە و . | A spam filter weighs the words of an email.فلتەری سپام وشەکانی ئیمەیڵێک دەکێشێت. |
| Artificial intelligenceبواری | Reasons and decides under uncertainty, in language processing and in computer vision. The notes call probability "the heart of AI".لە بارودۆخی نادڵنیادا بیر دەکاتەوە و بڕیار دەدات، لە و ناسینەوەی وێنەدا. تێبینییەکان بە «دڵی » ناو دەبەن. | Speech recognition and predictive text, earlier in this lesson. و ، لە پێشتری ئەم وانەیەدا. |
| Cryptographyبواری | Measures how likely an attacker is to guess or break a secret, to analyse protocols and design new ones that resist attacks.دەپێوێت هێرشبەر چەندە هەیە نهێنییەک مەزەندە بکات یان بیشکێنێت، بۆ شیکردنەوەی پرۆتۆکۆلەکان و دیزاینی پرۆتۆکۆلی نوێی بەرگەگر. | Guessing a random 128-bit key: per try.مەزەندەکردنی هەڕەمەکیی 128 : بۆ هەر هەوڵێک. |
Probability across computer scienceبەکارهێنانی ئەگەر لە سەرانسەری زانستی کۆمپیوتەردا
Cryptography: making a guess hopelessکریپتۆگرافی: بێهیواکردنی مەزەندە
Encryption is only as strong as its key. A 128-bit key is one of possible keys: two choices for each of the 128 bits, by the multiplication principle. If it is chosen at random, with every key equally likely, one guess is right with probability .
تەنها هێندەی بەهێزە. 128 یەکێکە لە گونجاو: بۆ هەر یەکێک لە 128 دوو هەڵبژاردن، بەپێی یاسای بنەڕەتی ژماردن. گەر بە هەڕەمەکی هەڵبژێردرێت و هەموو یەکسان لە ئەگەردا بن، ڕاستبوونی یەک مەزەندە ـە.
An attacker who tries keys one by one finds the right key, on average, halfway through: after about tries (an expected value). Even at a million million () tries per second:
هێرشبەرێک کە یەک بە یەک تاقی دەکاتەوە، بە تێکڕا لە نیوەی ڕێگادا کلیلە ڕاستەکە دەدۆزێتەوە: دوای نزیکەی هەوڵ (نرخی پێشبینیکراو). تەنانەت بە ملیۆن ملیۆن () هەوڵ لە چرکەیەکدا:
That is hundreds of millions of times the age of the universe (about years).
ئەمە سەدان ملیۆن هێندەی تەمەنی گەردوونە (نزیکەی ساڵ).
There is one condition: the key must really be random. A key made by a predictable generator can be guessed in a few thousand tries, as the last part of this lesson shows. Keys, ciphers and encryption are taught in Symmetric encryption: one shared key.
یەک مەرج هەیە: دەبێت بەڕاستی هەڕەمەکی بێت. کە بەرهەمهێنەرێکی پێشبینیکراو دروستی کردبێت، بە چەند هەزار هەوڵێک مەزەندە دەکرێت، وەک بەشی کۆتایی ئەم وانەیە نیشانی دەدات. ، و لە شفرەکردنی هاوچەشن: یەک کلیلی شفرەکردنی هاوبەش فێر دەکرێن.
Probability across computer scienceبەکارهێنانی ئەگەر لە سەرانسەری زانستی کۆمپیوتەردا
Three more fields: algorithms, queues and gamesسێ بواری تر: ئەلگۆریزمەکان، ڕیزی چاوەڕوانی و یاری
The other three fields use chance on purpose, or because customers and players are unpredictable.
سێ بوارەکەی تر یان ڕێکەوت بە مەبەست بەکار دەهێنن، یان پێویستیان پێیەتی چونکە ڕەفتاری کڕیار و یاریزان پێشبینی ناکرێت.
| Fieldبوار | What probability does thereڕۆڵی لەو بوارەدا | Exampleنموونە |
|---|---|---|
| Randomized algorithmsبواری | Algorithms that make random choices, to be faster on average or to solve problems that are hard to solve without chance; probability measures how well they do. کە هەڵبژاردنی هەڕەمەکی دەکەن، بۆ ئەوەی بە تێکڕا خێراتر بن یان کێشەیەک چارەسەر بکەن کە بێ ڕێکەوت قورسە؛ بە دەپێورێت چەندە باش کار دەکەن. | Quicksort with a random pivot avoids its slowest case (compare slow and fast sorting); a hash table spreads keys over its slots almost like random throws; the Monte Carlo method below. quicksort بە تەوەرێکی هەڕەمەکی لە خاوترین بارەکەی دوور دەکەوێتەوە (ڕیزکردنی خاو و خێرا بەراورد بکە)؛ خشتەیەکی هاش بە شێوەیەکی نزیک لە هەڕەمەکی بەسەر شوێنەکانیدا بڵاو دەکاتەوە؛ لە خوارەوە. |
| Queueing theoryبواری | Models waiting lines where customers or requests arrive at random times, such as computer networks and call centres.ڕیزی چاوەڕوانی مۆدێل دەکات کە کڕیار یان داواکاری لە کاتی هەڕەمەکیدا دێن، وەک تۆڕی و ناوەندی پەیوەندی. | How many servers a website needs so that users rarely wait; the field began with telephone calls in Copenhagen in 1909.ماڵپەڕێک چەند پێویستە بۆ ئەوەی بەکارهێنەران کەم چاوەڕێ بکەن؛ ئەم بوارە لە 1909ـدا بە پەیوەندیی تەلەفۆن لە کۆپنهاگن دەستی پێکرد. |
| Game theoryبواری | Studies situations where the result depends on several players' choices and on chance.ئەو بارودۆخانە دەخوێنێت کە ئەنجامەکەیان پشت بە هەڵبژاردنی چەند یاریزانێک و بە ڕێکەوت دەبەستێت. | A penalty kick: a kicker who always shoots to the same side is easy to stop, so the best plan is to choose sides at random with fixed probabilities.لێدانی پەنالتی: یاریزانێک کە هەمیشە بۆ هەمان لا لێدەدات ئاسان دەگیرێت، بۆیە باشترین پلان هەڵبژاردنی لایە بە هەڕەمەکی بە جێگیر. |
In short, probability is how computer science designs and analyses algorithms, reasons under uncertainty and predicts from data.
بە کورتی، زانستی بە دیزاین و شی دەکاتەوە، لە نادڵنیاییدا بیر دەکاتەوە و لە پێشبینی دەکات.
Earthquakes: probabilities of shaking, not datesبوومەلەرزە: ئەگەری لەرزین، نەک بەروار
The Kurdistan Region lies in the Zagros mountains, one of the world's active earthquake belts. On 12 November 2017 a magnitude 7.3 earthquake struck 29 km south of Halabja, near the Iran–Iraq border, and was felt across the region. Nobody can stop earthquakes, but engineers can design buildings to survive them, and for that they need probability.
هەرێمی کوردستان دەکەوێتە ناو چیاکانی زاگرۆسەوە، کە یەکێکە لە پشتێنە چالاکەکانی بوومەلەرزە لە جیهاندا. لە 12ی تشرینی دووەمی 2017 بوومەلەرزەیەک بە گەورەیی 7.3 لە 29 کیلۆمەتری باشووری هەڵەبجە، نزیک سنووری ئێران و عێراق، ڕوویدا و لە سەرانسەری ناوچەکەدا هەستی پێکرا. کەس ناتوانێت بوومەلەرزە ڕابگرێت، بەڵام ئەندازیاران دەتوانن بینا بە شێوەیەک دیزاین بکەن کە بەرگەی بگرێت. بۆ ئەمەش پێویستە.
Probabilistic seismic hazard analysis (PSHA) is the method they use. It combines the region's past earthquakes (its seismicity), geological information about faults (their shape and how active they are), the seismicity of nearby regions and other factors into one mathematical model. The model estimates the probability of different levels of ground shaking at a site, caused by earthquakes of different sizes at different distances.
(PSHA) ئەو ڕێگایەیە کە بەکاری دەهێنن. بوومەلەرزەکانی ڕابردووی ناوچەکە، زانیاریی جیۆلۆجی دەربارەی شکاوییەکانی زەوی (شێوەیان و چەند چالاکن)، بوومەلەرزەکانی ناوچە نزیکەکان و هۆکاری تر لە یەک مۆدێلی بیرکاریدا کۆ دەکاتەوە. مۆدێلەکە ئاستە جیاوازەکانی لەرزینی زەوی لە شوێنێکدا دەخەمڵێنێت، کە بوومەلەرزەی قەبارە جیاواز لە دووریی جیاوازەوە دروستی دەکەن.
Earthquakes: probabilities of shaking, not datesبوومەلەرزە: ئەگەری لەرزین، نەک بەروار
The hazard curve, and what it cannot doچەماوەی مەترسیی بوومەلەرزە و ئەوەی ناتوانێت بیکات
The result is a seismic hazard curve: for each level of shaking, the probability that it is exceeded at that place within a time period, such as 50 years. Engineers use it to design buildings, bridges and other structures that can withstand earthquakes. Building codes often design for the shaking that has a 2% probability of being exceeded in 50 years; the hazard maps of the United States Geological Survey (USGS) show exactly this.
ئەنجامەکە : بۆ هەر ئاستێکی لەرزین، ئەوەی لەو شوێنەدا لە ماوەیەکی دیاریکراودا، وەک پەنجا ساڵ، تێپەڕێت. ئەندازیاران بۆ دیزاینی بینا، پرد و پێکهاتەی تر بەکاری دەهێنن کە بەرگەی بوومەلەرزە بگرن. یاساکانی بیناسازی زۆرجار بۆ ئەو لەرزینە دیزاین دەکەن کە تێپەڕاندنی لە پەنجا ساڵدا دوو لە سەدە؛ نەخشەکانی مەترسیی ڕێکخراوی ڕووپێوی جیۆلۆجیی ئەمریکا (USGS) ڕێک ئەمە نیشان دەدەن.
Earthquakes: probabilities of shaking, not datesبوومەلەرزە: ئەگەری لەرزین، نەک بەروار
What does "2% in 50 years" mean?«دوو لە سەد لە پەنجا ساڵدا» واتای چییە؟
Suppose each year has the same small probability that the shaking goes above the design level, and years are independent. "At least once in 50 years" is the complement of "not in any of the 50 years":
وا دابنێ هەر ساڵێک هەمان بچووکی ی هەیە کە لەرزین لە ئاستی دیزاین تێپەڕێت و ساڵەکان سەربەخۆن. «لانیکەم جارێک لە پەنجا ساڵدا» ڕووداوی تەواوکەری «لە هیچ یەکێک لە پەنجا ساڵەکەدا نا»یە:
So "2% in 50 years" means about 1 chance in 2,475 in any one year. Engineers call 2,475 years the return period. In the same way, "10% in 50 years" means about 1 in 475 per year.
کەواتە «دوو لە سەد لە پەنجا ساڵدا» واتە نزیکەی یەک لە لە هەر ساڵێکدا. ئەندازیاران ساڵ ناو دەنێن . بە هەمان شێوە «دە لە سەد لە پەنجا ساڵدا» واتە نزیکەی یەک لە لە ساڵێکدا.
Random numbers from a machine that follows rulesژمارە هەڕەمەکییەکان لە ئامێرێکەوە کە یاسا جێبەجێ دەکات
A computer follows its instructions exactly: the same steps always give the same result. So where do Python's random numbers come from? From a formula. The random module uses a pseudo-random number generator called the Mersenne Twister. Starting from a number called the seed, it produces a long sequence that looks random and passes statistical tests, and only repeats after numbers. random.random() returns a number from 0 up to (not including) 1, in the interval , with every part of that interval equally likely (a uniform distribution).
ڕێنماییەکانی بە وردی جێبەجێ دەکات: هەمان هەنگاو هەمیشە هەمان ئەنجام دەدات. کەواتە Python لە کوێوە دێن؟ لە هاوکێشەیەکەوە. random بەرهەمهێنەری بەکار دەهێنێت کە ناوی Mersenne Twisterـە. لە ژمارەیەکەوە دەست پێ دەکات کە پێی دەگوترێت ، زنجیرەیەکی درێژ بەرهەم دەهێنێت کە هەڕەمەکی دیارە و لە تاقیکردنەوە ئامارییەکان دەردەچێت و تەنها دوای ژمارە دووبارە دەبێتەوە. random.random() ژمارەیەک لە ـدا دەگەڕێنێتەوە، واتە لە 0 تا 1 بەبێ خودی 1. هەموو بەشێکی ئەو هەمان هەیە (دابەشبوونی یەکنەواخت).
Think of a book with millions of pages of random-looking digits, sold in every bazaar. The seed tells you which page to start on. Two people who start on the same page read the same "random" digits: perfect for repeating an experiment or finding a bug. But anyone who learns your page can read ahead of you.
کتێبێک بهێنە پێش چاوت کە ملیۆنان پەڕە ژمارەی تێدایە کە هەڕەمەکی دیارن و لە هەموو بازاڕێک دەفرۆشرێت. پێت دەڵێت لە کام پەڕەوە دەست پێ بکەیت. دوو کەس کە لە هەمان پەڕەوە دەست پێ دەکەن هەمان ژمارە «هەڕەمەکی»ـیەکان دەخوێننەوە: نایابە بۆ دووبارەکردنەوەی تاقیکردنەوەیەک یان دۆزینەوەی هەڵەیەک. بەڵام هەر کەسێک پەڕەکەت بزانێت دەتوانێت پێش تۆ بخوێنێتەوە.
Where the analogy stops workingسنووری ئەم نموونەیە
The generator does not store a book; it computes each number from the previous state, and its "book" is far too long to read to the end.
بەرهەمهێنەرەکە کتێب هەڵناگرێت؛ هەر ژمارەیەک لە دۆخی پێشووەوە حیساب دەکات. ئەو «کتێبە»ش هێندە درێژە کە هەرگیز ناگەیتە کۆتاییەکەی.
A random number generator is a formula started from a seed: the same seed gives the same numbers, so security needs a secure generator.
دروستکەری کە لە دەست پێدەکات: هەمان هەمان ژمارەکان دەدات، بۆیە پێویستی بە دروستکەرێکی پارێزراو هەیە.
Whole video (5 minutes): what an RNG is, seeding (1:49), why rand() is predictable, and a secure generator (OpenSSL, 3:53).
هەموو ڤیدیۆکە (5 خولەک): دروستکەری چییە، دانانی (1:49)، بۆچی rand() پێشبینی دەکرێت، هەروەها دروستکەرێکی پارێزراو (OpenSSL، 3:53).
Random numbers from a machine that follows rulesژمارە هەڕەمەکییەکان لە ئامێرێکەوە کە یاسا جێبەجێ دەکات
Monte Carlo: estimating π with random pointsڕێگای مۆنتی کارلۆ: خەمڵاندنی π بە خاڵی هەڕەمەکی
You already used random to toss a coin 1,000 times; its everyday tools are in The random module.
پێشتر randomـت بۆ هەڵدانی دراوێک هەزار جار بەکار هێنا؛ ئامرازە ڕۆژانەکانی لە مۆدیوڵی random دەناسیت.
Here is a surprising use of chance: computing a number that has nothing random about it. Pick a point at random in a square, with both coordinates from random.random(). The quarter circle of radius 1 covers of the square's area, so the probability that the point lands inside it is . By the law of large numbers, the share of points inside settles near , and four times that share settles near π.
ئەمە بەکارهێنانێکی سەرسوڕهێنەری ڕێکەوتە: حیسابکردنی ژمارەیەک کە هیچ شتێکی هەڕەمەکیی تێدا نییە. خاڵێک بە هەڕەمەکی لە چوارگۆشەیەکی ـدا هەڵبژێرە، هەردوو ڕێکخەرەکەی لە random.random()ـەوە. چارەکە بازنەی نیوەتیرە 1 ی ڕووبەری چوارگۆشەکە دادەپۆشێت، بۆیە کەوتنی خاڵەکە لە ناویدا ـە. بەپێی یاسای ژمارە گەورەکان، بەشی ئەو خاڵانەی دەکەونە ناوەوە لە نزیک دەگیرسێتەوە و چوار هێندەی ئەو بەشە لە نزیک π.


This is the Monte Carlo method: answer a question by repeating a random experiment many times and counting. It was named in the 1940s by scientists at Los Alamos (Stanisław Ulam, John von Neumann and Nicholas Metropolis), after the famous casino in Monaco, and today it is used for risk in engineering and finance, for physics and for game-playing AI.
ئەمە ـە: وەڵامدانەوەی پرسیارێک بە دووبارەکردنەوەی بۆ زۆر جار و ژماردن. لە ساڵانی چلەکاندا زانایانی لۆس ئەلامۆس (ستانیسواڤ ئولام، جۆن ڤۆن نۆیمان و نیکۆلاس مێترۆپۆلیس) ئەم ناوەیان لێنا، بە ناوی یانە بەناوبانگەکەی قوماری مۆناکۆ. ئەمڕۆ بۆ لە ئەندازیاری و دارایی، بۆ فیزیا و بۆ یاریکردن بەکار دێت.
Random numbers from a machine that follows rulesژمارە هەڕەمەکییەکان لە ئامێرێکەوە کە یاسا جێبەجێ دەکات
The π experiment in Pythonتاقیکردنەوەی π لە Pythonـدا
import random
random.seed(7) # fixed seed: the same points on every run
inside = 0
for n in range(1, 100_001):
x = random.random() # a number from 0 up to (not including) 1
y = random.random()
if x * x + y * y <= 1: # inside the quarter circle of radius 1
inside += 1
if n in (100, 1_000, 10_000, 100_000):
print(f"{n:>7} points: {inside:>6} inside, pi is about {4 * inside / n:.4f}")100 points: 79 inside, pi is about 3.1600 1000 points: 788 inside, pi is about 3.1520 10000 points: 7874 inside, pi is about 3.1496 100000 points: 78556 inside, pi is about 3.1422
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 3
The fixed seed makes your run print exactly these numbers. Remove the line to get a new experiment each time.
جێگیر وا دەکات جێبەجێکردنەکەت ڕێک ئەم ژمارانە چاپ بکات. ئەم دێڕە لاببە بۆ ئەوەی هەر جارە تاقیکردنەوەیەکی نوێ بکەیت.
- Lineدێڕی 7
A point is inside the quarter circle when its distance from the corner is at most 1, that is .
خاڵێک لە ناو چارەکە بازنەکەدایە کاتێک دووریی لە گۆشەکەوە لە 1 زیاتر نەبێت، واتە .
- Lineدێڕی 10
The estimate after 100, 1,000, 10,000 and 100,000 points.
خەمڵاندنەکە دوای 100، 1,000، 10,000 و 100,000 خاڵ.
With 100 points the estimate is off by about 0.02; with 100,000 points it is off by less than 0.001. The error of a Monte Carlo estimate shrinks roughly like : to make it 10 times smaller you need about 100 times as many points. Your own run without a seed gives different numbers, but the same pattern.
بە 100 خاڵ خەمڵاندنەکە نزیکەی 0.02 هەڵەیە؛ بە خاڵ کەمتر لە 0.001 هەڵەیە. هەڵەی خەمڵاندنی بە نزیکەیی وەک بچووک دەبێتەوە: بۆ ئەوەی دە جار بچووکتر بێت، نزیکەی سەد هێندە خاڵت پێویستە. جێبەجێکردنی خۆت بێ ژمارەی جیاواز دەدات، بەڵام هەمان شێوە.
Random numbers from a machine that follows rulesژمارە هەڕەمەکییەکان لە ئامێرێکەوە کە یاسا جێبەجێ دەکات
When chance must stay secretکاتێک ڕێکەوت دەبێت نهێنی بمێنێتەوە
For a simulation, a repeatable "random" sequence is a gift. For security it is a disaster. Imagine a server that makes 6-digit login codes with random, seeded with the clock: the number of the current second. An attacker who knows the code was made in the last hour only has to try 3,601 seeds:
بۆ ، زنجیرەیەکی «هەڕەمەکی»ی دووبارەکراو دیارییە. بۆ کارەساتە. بهێنە پێش چاوت کە کۆدی چوونەژوورەوەی شەش ژمارەیی بە random دروست دەکات و کاتژمێرەکەیە: ژمارەی چرکەی ئێستا. هێرشبەرێک کە دەزانێت کۆدەکە لە دوایین کاتژمێردا دروست کراوە، تەنها پێویستە 3,601 تاقی بکاتەوە:
import random
made_at = 1_761_300_000 # the second (Unix time) when the server made the code
random.seed(made_at) # BAD: the seed is just the clock
code = random.randint(100000, 999999)
# An attacker knows the code was made during the last hour: only 3,601 possible seeds.
tries = 0
for guess in range(made_at - 3600, made_at + 1):
tries += 1
random.seed(guess)
if random.randint(100000, 999999) == code:
print("seed found after", tries, "tries; the code is", code)
breakseed found after 3601 tries; the code is 873854
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 4
BAD: the seed is just the time, so it can be guessed.
خراپ: تەنها کاتەکەیە، بۆیە مەزەندە دەکرێت.
- Lineدێڕی 8-14
The attacker repeats the server's steps for every possible second until the same code comes out.
هێرشبەر هەنگاوەکانی بۆ هەموو چرکەیەکی گونجاو دووبارە دەکاتەوە تا هەمان کۆد دەردەچێت.
A random guess at a 6-digit code (100000 to 999999) is right with probability . Knowing the seed rule turns that into certainty after at most 3,601 tries. Python's documentation says it plainly: the generators in random should not be used for security; use the secrets module, which draws on the most secure randomness the operating system provides. There is no seed to guess:
مەزەندەیەکی هەڕەمەکی بۆ کۆدێکی شەش ژمارەیی (100000 تا 999999) بە ڕاستە. زانینی یاسای ئەمە دوای لانیزۆر 3,601 هەوڵ دەکات بە دڵنیایی. بەڵگەنامەکانی Python بە ڕوونی دەیڵێن: نابێت بەرهەمهێنەرەکانی random بۆ بەکار بهێنرێن؛ secrets بەکار بهێنە، کە لە پارێزراوترین سەرچاوەی ڕێکەوتی وەردەگرێت. هیچ نییە بۆ مەزەندەکردن:
secretsـەوەPYTHONimport secrets
code = secrets.randbelow(900000) + 100000 # 100000 ... 999999, from the operating system
print("login code:", code)login code: 359344
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 3
randbelow(900000)gives 0 to 899999; adding 100000 gives a 6-digit code. Your output is different on every run.randbelow(900000)ژمارەیەک لە 0 تا 899999 دەدات؛ زیادکردنی 100000 کۆدێکی شەش ژمارەیی دەدات. لە هەر جێبەجێکردنێکدا جیاوازە.
The same rule protects every password, reset link and token: an attacker's chance must stay as small as the counting says. Why a password must be random, not only long, is taught in Long is not enough: it must be random; the full random and secrets toolbox is in the Python track, random is not for passwords: secrets.
هەمان یاسا هەموو ، گۆڕینەوە و نیشانەیەکی ئاسایش دەپارێزێت: هێرشبەر دەبێت هێندە بچووک بمێنێتەوە کە ژماردنەکە دەڵێت. بۆچی دەبێت هەڕەمەکی بێت، نەک تەنها درێژ، لە درێژی بەس نییە: دەبێت هەڕەمەکی بێت فێر دەکرێت؛ هەموو ئامرازەکانی random و secrets لە بەشی Pythonـدان، random بۆ تێپەڕەوشە نییە: secrets.
Common mistakesهەڵە باوەکان
- "The phone knows what I said." It only computes the most probable text. When two texts sound alike, it can choose the wrong one.
- Confusing with . store is not a common word overall, but after I am going to the it is the most probable one.
- Thinking a hazard map gives the date of the next earthquake. It gives probabilities of shaking over a period; nobody can predict the day.
- Reading "once in 2,475 years" as "safe for a long time". The probability is the same every year.
- Adding probabilities of "at least once". For two independent 50-year periods at 10%, the answer is , not 0.20.
- Thinking a seed makes numbers "more random". A seed makes them repeatable.
- Using
randomfor passwords, codes or keys. Usesecrets.
- «مۆبایلەکە دەزانێت چیم گوت.» تەنها گونجاوترین دەق حیساب دەکات. کاتێک دوو دەق دەنگیان لە یەک دەچێت، دەکرێت هەڵەکەیان هەڵبژێرێت.
- تێکەڵکردنی لەگەڵ . store بە گشتی وشەیەکی زۆر باو نییە، بەڵام دوای I am going to the گونجاوترینە.
- وابزانیت نەخشەی مەترسی بەرواری بوومەلەرزەی داهاتوو دەدات. لەرزین بۆ ماوەیەک دەدات؛ کەس ناتوانێت ڕۆژەکە پێشبینی بکات.
- خوێندنەوەی «جارێک لە ساڵدا» وەک «بۆ ماوەیەکی درێژ سەلامەت». هەموو ساڵێک وەک یەکە.
- کۆکردنەوەی «لانیکەم جارێک». بۆ دوو ماوەی پەنجا ساڵیی سەربەخۆ بە دە لە سەد، وەڵامەکە ـە، نەک 0.20.
- وابزانیت ژمارەکان «هەڕەمەکیتر» دەکات. دووبارەکراویان دەکات.
- بەکارهێنانی
randomبۆ ، کۆد یان .secretsبەکار بهێنە.
Exercisesڕاهێنانەکان
In 100 messages, see you was followed by tomorrow 40 times, soon 25, later 15, there 10, Saturday 6 and Sunday 4. (a) Give the probability of each word. (b) Which three words does the keyboard suggest? (c) The user types the letter s. Which words still fit, and what are their new probabilities?
لە 100 نامەدا، دوای see you وشەی tomorrow 40 جار هات، soon 25، later 15، there 10، Saturday 6 و Sunday 4. (أ) هەر وشەیەک بدۆزەرەوە. (ب) کام سێ وشە پێشنیار دەکات؟ (ج) بەکارهێنەر پیتی s دەنووسێت. کام وشانە هێشتا دەگونجێن و نوێیەکانیان چەندن؟
Show answerوەڵامەکە پیشان بدە
- (a) 0.40, 0.25, 0.15, 0.10, 0.06, 0.04 (they add up to 1).
- (b) tomorrow, soon, later.
- (c) soon, Saturday and Sunday fit, 35 messages in all: , , .
- (أ) 0.40، 0.25، 0.15، 0.10، 0.06، 0.04 (کۆکەیان 1ـە).
- (ب) tomorrow، soon، later.
- (ج) soon، Saturday و Sunday دەگونجێن، کۆی گشتی 35 نامە: ، ، .
A recogniser hears one short phrase. For recognise speech: , . For wreck a nice beach: , . Which text does it output, and how many times more probable is it?
سیستەمێکی ناسینەوە دەستەواژەیەکی کورت دەبیستێت. بۆ recognise speech: ، . بۆ wreck a nice beach: ، . کام دەق دەکاتە و چەند جار زیاترە؟
Hintئاماژە
Multiply the two probabilities for each text, then compare.
بۆ هەر دەقێک دوو لێکبدە، پاشان بەراوردیان بکە.
Show answerوەڵامەکە پیشان بدە
recognise speech wins: it is 20 times more probable, although wreck a nice beach matches the sound a little better.
recognise speech دەباتەوە: بیست جار زیاترە، هەرچەندە wreck a nice beach کەمێک باشتر لەگەڵ دەنگەکە دەگونجێت.
A bridge is designed for shaking with a 10% probability of being exceeded in 50 years. Assume independent years. (a) Find the probability for one year and the return period. (b) Find the probability that the shaking is exceeded at least once in 100 years.
پردێک بۆ لەرزینێک دیزاین کراوە کە تێپەڕاندنی لە پەنجا ساڵدا دە لە سەدە. ساڵەکان بە سەربەخۆ دابنێ. (أ) بۆ یەک ساڵ و بدۆزەرەوە. (ب) ئەوە بدۆزەرەوە کە لەرزینەکە لانیکەم جارێک لە سەد ساڵدا تێپەڕێت.
Show answerوەڵامەکە پیشان بدە
Return period: about 475 years.
: نزیکەی ساڵ.
(a) 7,862 of 10,000 random points fall inside the quarter circle. Estimate π. (b) Your estimate with 10,000 points is off by about 0.003. Roughly how many points would make a typical error 10 times smaller?
(أ) 7,862 لە 10,000 خاڵی هەڕەمەکی دەکەونە ناو چارەکە بازنەکەوە. π بخەمڵێنە. (ب) خەمڵاندنەکەت بە 10,000 خاڵ نزیکەی 0.003 هەڵەیە. نزیکەی چەند خاڵ هەڵەیەکی ئاسایی دە جار بچووکتر دەکات؟
Show answerوەڵامەکە پیشان بدە
- (a) .
- (b) About 100 times as many: points, because the error shrinks like . (One run can be luckier or unluckier than typical.)
- (أ) خەمڵاندن: .
- (ب) نزیکەی سەد هێندە: خاڵ، چونکە هەڵەکە وەک بچووک دەبێتەوە. (یەک جێبەجێکردن دەکرێت بەختی لە ئاسایی باشتر یان خراپتر بێت.)
random یان secrets؟Choose the module for each job and give the reason: (a) shuffling the questions of a practice quiz so that a teacher can reproduce the order; (b) a one-time login code sent by SMS; (c) a dice game for children; (d) a link for resetting a password. (e) What is the probability that one random guess of a 6-digit code (100000 to 999999) is right?
بۆ هەر کارێک هەڵبژێرە و هۆکارەکەی بڵێ: (أ) تێکەڵکردنی پرسیارەکانی تاقیکردنەوەیەکی ڕاهێنان بە شێوەیەک مامۆستا بتوانێت ڕیزبەندییەکە دووبارە بکاتەوە؛ (ب) کە بە SMS دەنێردرێت؛ (ج) یاریی بەردەزار بۆ منداڵان؛ (د) بۆ گۆڕینی . (هـ) ئەوە چەندە کە یەک مەزەندەی هەڕەمەکی بۆ کۆدێکی شەش ژمارەیی (100000 تا 999999) ڕاست بێت؟
Show answerوەڵامەکە پیشان بدە
- (a)
randomwith a fixed seed: the order must repeat. - (b)
secrets: an attacker must not be able to predict it. - (c)
random: nothing secret is at stake. - (d)
secrets, for examplesecrets.token_urlsafe(). - (e) .
- (أ)
randomبە جێگیر: ڕیزبەندییەکە دەبێت دووبارە ببێتەوە. - (ب)
secrets: نابێت هێرشبەر بتوانێت پێشبینیی بکات. - (ج)
random: هیچ نهێنییەک لە مەترسیدا نییە. - (د)
secrets، بۆ نموونەsecrets.token_urlsafe(). - (هـ) دەکاتە .
Name the field from the two tables of computer science fields: (a) a model learns to recognise handwritten digits from thousands of noisy examples; (b) an online shop works out how many checkout servers it needs on a busy day; (c) a goalkeeper and a penalty taker each choose a side; (d) a sorting program picks its pivot at random.
بوارەکە لە هەردوو خشتەی بوارەکانی زانستی ناو بنێ: (أ) لە هەزاران نموونەی ژاوەژاویدار فێری ناسینەوەی ژمارەی دەستنووس دەبێت؛ (ب) فرۆشگایەکی ئۆنلاین حیساب دەکات لە ڕۆژێکی قەرەباڵغدا چەند پارەدانی پێویستە؛ (ج) گۆڵپارێزێک و لێدەری پەنالتییەک هەر یەکەیان لایەک هەڵدەبژێرن؛ (د) تەوەرەکەی بە هەڕەمەکی هەڵدەبژێرێت.
Show answerوەڵامەکە پیشان بدە
- (a) Machine learning.
- (b) Queueing theory.
- (c) Game theory.
- (d) Randomized algorithms.
- (أ) بواری .
- (ب) بواری .
- (ج) بواری .
- (د) بواری .
Summaryپوختە
- Speech recognition outputs the most probable text for the sound: Bayes multiplies how well a text matches the sound by how common the text is. HMMs did this from the 1980s; neural networks do it today.
- Predictive text ranks words by the conditional probability of the next word given what you typed; each letter shrinks the list. A language model gives probabilities of word sequences.
- Machine learning, AI, cryptography, randomized algorithms, queueing theory and game theory all depend on probability.
- PSHA gives the probability that shaking at a place is exceeded within a period (a hazard curve); "2% in 50 years" is about 1 in 2,475 per year. It does not predict earthquakes.
randomis pseudo-random and repeatable with a seed: good for simulations such as the Monte Carlo estimate of π. For passwords, codes and keys usesecrets.
- گونجاوترین دەق بۆ دەنگەکە دەکاتە : گونجانی دەقێک لەگەڵ دەنگەکە لە باوبوونی دەقەکە دەدات. لە هەشتاکانەوە ئەمەی دەکرد؛ ئەمڕۆ دەیکەن.
- وشەکان بە پێی ی وشەی دواتر ڕیز دەکات، بە مەرجی ئەوەی نووسیوتە؛ هەر پیتێک لیستەکە بچووک دەکاتەوە. زنجیرەی وشە دەدات.
- ، ، ، ، و هەموویان پشت بە دەبەستن.
- تێپەڕاندنی لەرزین لە شوێنێکدا لە ماوەیەکدا دەدات ()؛ «دوو لە سەد لە پەنجا ساڵدا» نزیکەی یەک لە ـە لە ساڵێکدا. پێشبینیی بوومەلەرزە ناکات.
randomنیمچەهەڕەمەکییە و بە دووبارە دەبێتەوە: باشە بۆ وەک خەمڵاندنی π بە . بۆ ، کۆد وsecretsبەکار بهێنە.
Why does a keyboard's top suggestion change when you type one more letter?بۆچی باشترین پێشنیاری کیبۆرد دەگۆڕێت کاتێک پیتێکی تر دەنووسیت؟
Words that do not start with the new letters drop out, so the probability is shared among fewer words: a smaller sample space.
ئەو وشانەی بە پیتە نوێیەکان دەست پێ ناکەن دەردەچن، بۆیە لە نێوان وشەی کەمتردا دابەش دەبێت: بچووکتر.
Can PSHA tell us the year of the next big earthquake in the Zagros?دەتوانێت شیکاریی ئەگەریی مەترسیی بوومەلەرزە ساڵی بوومەلەرزە گەورەکەی داهاتووی زاگرۆسمان پێ بڵێت؟
No. It gives probabilities of shaking over a period; nobody can predict the time, place and size of a single earthquake.
نەخێر. لەرزین بۆ ماوەیەک دەدات؛ کەس ناتوانێت کات، شوێن و قەبارەی یەک بوومەلەرزە پێشبینی بکات.
Why is a fixed seed useful in the π program but dangerous in a login system?بۆچی تۆوێکی هەڕەمەکیی جێگیر بۆ بەرنامەی خەمڵاندنی π بەسوودە بەڵام لە سیستەمی چوونەژوورەوەدا مەترسیدارە؟
It makes the numbers repeat. Repeating helps you check a simulation, but it lets an attacker reproduce a secret code.
ژمارەکان دووبارە دەکاتەوە. دووبارەبوونەوە یارمەتیت دەدات بپشکنیت، بەڵام ڕێگە بە هێرشبەر دەدات کۆدێکی نهێنی دووبارە دروست بکاتەوە.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Project: Predicting a Football Match with Probabilityپرۆژە: پێشبینیکردنی یارییەکی تۆپی پێ بە ئەگەر
Related lecturesوانە پەیوەندیدارەکان
- Project: Predicting a Football Match with Probabilityپرۆژە: پێشبینیکردنی یارییەکی تۆپی پێ بە ئەگەر
- The Axioms of Probability and the Complement Ruleبەڵگەنەویستەکانی ئەگەر و یاسای تەواوکەر
- Expected Value (Mathematical Expectation)نرخی پێشبینیکراو (چاوەڕوانیی بیرکاری)
- Machine Learning Basics (Supplementary)بنەماکانی فێربوونی ئامێر (زیادە)
- Modules and importمۆدیوڵەکان و import
- Encryption, Hashing and Digital Signaturesشفرەکردن، هاشکردن و واژووە دیجیتاڵییەکان
- Passwords, MFA and Access Controlتێپەڕەوشەکان، MFA و کۆنترۆڵی دەستڕاگەیشتن
- What Is Statistics? Data, Populations and Samplesئامار چییە؟ دراوە، کۆمەڵگە و نموونە
- Counting and Permutationsژماردن و گۆڕینەکان
- What Is Artificial Intelligence?ژیریی دەستکرد چییە؟
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- Wikipedia: Speech recognition (HMMs from the 1980s, 10 ms frames, acoustic and language modelling, deep learning, end-to-end CTC 2014 and Listen-Attend-Spell 2016)
- Jurafsky & Martin, Speech and Language Processing (3rd ed. draft), Chapter 3: N-gram Language Models (next-word probabilities from counts, chain rule, uses in speech recognition and word prediction)
- Apple Newsroom (June 2023): iOS 17 keyboard with a transformer language model for word prediction
- Wikipedia: Randomized algorithm (random-pivot quicksort, Las Vegas and Monte Carlo algorithms)
- Wikipedia: Queueing theory (Erlang, Copenhagen Telephone Exchange, 1909)
- Wikipedia: Strategy (game theory) (mixed strategies; the penalty-kick example)
- USGS: Can you predict earthquakes?
- USGS Earthquake Hazards Program: Hazards (ground shaking with 2% probability of being exceeded in 50 years)
- USGS event page: M 7.3, 29 km S of Halabja, Iraq, 12 November 2017
- Python documentation: random — Generate pseudo-random numbers (Mersenne Twister, seeds, not for security)
- Python documentation: secrets — Generate secure random numbers for managing secrets
- Wikipedia: Monte Carlo method (estimating π, error like 1/√N, Ulam and von Neumann at Los Alamos)
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.