{"id":626,"date":"2008-04-09T11:49:41","date_gmt":"2008-04-09T11:49:41","guid":{"rendered":"http:\/\/scientopia.org\/blogs\/goodmath\/2008\/04\/09\/random-variables\/"},"modified":"2008-04-09T11:49:41","modified_gmt":"2008-04-09T11:49:41","slug":"random-variables","status":"publish","type":"post","link":"http:\/\/www.goodmath.org\/blog\/2008\/04\/09\/random-variables\/","title":{"rendered":"Random Variables"},"content":{"rendered":"<p> The first key concept in probability is called a <em>random variable<\/em>.<br \/>\nRandom variables are a key concept &#8211; but since they&#8217;re a key concept of the<br \/>\nfrequentist school, they are alas, one of the things that bring out more of<br \/>\nthe Bayesian wars. But the idea of the random variable, and its key position<br \/>\nin understanding probability and statistics predates the divide between<br \/>\nfrequentist and Bayesian though. So please, folks, be a little bit patient,<br \/>\nand don&#8217;t bring the Bayesian flamewars into this post, OK? If you want to<br \/>\nrant about how stupid frequentist explanations are, please keep it in the comments <a href=\"http:\/\/scientopia.org\/blogs\/goodmath\/2008\/04\/schools-of-thought-in-probability-theory\">here<\/a>. I&#8217;m trying to<br \/>\nexplain basic ideas, and you really can&#8217;t talk about probability and<br \/>\nstatistics without talking about random variables.<\/p>\n<p><!--more--><\/p>\n<p> A random variable is an abstract representation of a measurable outcome of<br \/>\na repeated experiment. A very typical example is die rolling: if you&#8217;re<br \/>\nrolling three common six-sided dice, a reasonable random variable would be the<br \/>\nsum of their faces. A random variable doesn&#8217;t have to be a single number:<br \/>\nroughly speaking, it can be anything that corresponds to a representation of<br \/>\nthe outcome of the experiment. For example, a different random variable<br \/>\nfor the dice-rolling experiment could be a a triple containing the values of each of the dice. (There&#8217;s actually a bit more to the requirements on<br \/>\nwhat makes a valid type of value for a random variable, but it gets pretty hairy, so I&#8217;ve just sticking with the intuition here.)<\/p>\n<p> The random variable isn&#8217;t the outcome of a single experiment: conceptually, it&#8217;s a representation of the outcome an infinite series of identical trials. It&#8217;s the statistical definition of the concept of<br \/>\noutcome for the experiment.<\/p>\n<p> A random variable is thus much more than just a number, or a set of numbers. It&#8217;s the carrier of the probabilistic properties of what you&#8217;re measuring. For example, in the 3-die rolling example above, when you roll<br \/>\nthree dice, you can get a value ranging from 3 to 18, and the different<br \/>\nvalues can occur with <em>different<\/em> frequency. For example, there&#8217;s only<br \/>\none way to roll a &#8220;3&#8221; (Rolling a one on each die: {(1,1,1)}); but there are<br \/>\nthree ways to roll a 4 (2 dice with a one, one with a 2. But the 2 could be<br \/>\nany of the three dices: {(1,1,2), (1,2,1), (2,1,1)}).<\/p>\n<p> That idea, that the range of values covered by the random variable<br \/>\nhave different frequencies, is represented by something called a<br \/>\n<em>probability distribution<\/em>. (Strictly speaking, it could also be<br \/>\na probability <em>density function<\/em> for a continuous random<br \/>\nvariable, but I&#8217;m sticking with the simpler discrete version.) The<br \/>\nprobability distribution basically describes the ratio of occurrences<br \/>\nof the different outcomes in an ideal, infinite set of trials. For example,<br \/>\nsuppose we wanted to look at rolling two dice. (Three is too many possibilities to be easy to read.) Below is a table of<br \/>\nthe possible outcomes of rolling two dice:<\/p>\n<table border=\"1\">\n<tr>\n<th>Sum<\/th>\n<th>Count<\/th>\n<th>Rolls<\/th>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>1<\/td>\n<td>(1,1)<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>2<\/td>\n<td>(2,1), (1,2)<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>3<\/td>\n<td>(1,3), (2,2), (3,1)<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>4<\/td>\n<td>(2,3), (3,2), (1,4), (4,1)<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>5<\/td>\n<td>(1,5), (2,4), (3,3), (4,2), (5,1)<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>6<\/td>\n<td>(1,6), (2,5), (3,4), (4,3), (5,2), (6,1)<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td>5<\/td>\n<td>(2,6), (3,5), (4,4), (5,3), (6,2)<\/td>\n<\/tr>\n<tr>\n<td>9<\/td>\n<td>4<\/td>\n<td>(3,6), (4,5), (5,4), (6,3)<\/td>\n<\/tr>\n<tr>\n<td>10<\/td>\n<td>3<\/td>\n<td>(4,6), (5,5), (6,4)<\/td>\n<\/tr>\n<tr>\n<td>11<\/td>\n<td>2<\/td>\n<td>(5,6), (6,5)<\/td>\n<\/tr>\n<tr>\n<td>12<\/td>\n<td>1<\/td>\n<td>(6,6)<\/td>\n<\/tr>\n<\/table>\n<p> The <em>probability distribution<\/em> is defined by the ratio<br \/>\nof the number I labelled as &#8220;count&#8221; in the table above to the<br \/>\nnumber of possible outcomes. Which is another way of saying that<br \/>\nif you took a random trial, and looked at the value of the random<br \/>\nvariable, then the probability distribution tells you how<br \/>\nlikely each possible outcome is to be the value of the variable. For<br \/>\nthe table above, the distribution is:<\/p>\n<table border=\"1\">\n<tr>\n<th>Sum<\/th>\n<th>Probability<\/th>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>1\/36<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>2\/36=1\/18<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>3\/36=1\/12<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>4\/36=1\/9<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>5\/36<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>6\/36=1\/6<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td>5\/36<\/td>\n<\/tr>\n<tr>\n<td>9<\/td>\n<td>4\/36=1\/9<\/td>\n<\/tr>\n<tr>\n<td>10<\/td>\n<td>3\/36=1\/12<\/td>\n<\/tr>\n<tr>\n<td>11<\/td>\n<td>2\/36=1\/18<\/td>\n<\/tr>\n<tr>\n<td>12<\/td>\n<td>1\/36<\/td>\n<\/tr>\n<\/table>\n<p> So if you randomly select trials of die rolling, that means that<br \/>\nyou would expect that, on average, one out of every 36<br \/>\nrolls would have a sum of 2.<\/p>\n<p> According to the simplest definition of probability (which is<br \/>\nnow considered to be part of the frequentist school), that&#8217;s what<br \/>\nit means to have a probability of 1\/36: given a series of trials,<br \/>\non average, one out of every 36 trials would produce that result. (The<br \/>\nBayesian version would be, roughly, if you look at a particular trial,<br \/>\nwith no knowledge other than that it was a fair set of dice, you&#8217;d have<br \/>\na certainty of 1\/36 that the outcome would be a 2.)\t<\/p>\n<p> Given the probability distribution for a random variable, you can<br \/>\nanalyze its properties. For a simple example, there&#8217;s an idea called<br \/>\nthe <em>expectation<\/em> of a random variable. Given a random variable x, the expectation <b>E<\/b>(x) is essentially a probabilistic mean. If the probability distribution of x is given by p(a) : a&isin;range(x), then<br \/>\n<b>E<\/b>(x)=&Sigma;<sub>a&isin;range(x)<\/sub>: a&times;p(a).<\/p>\n<p> So for our two-die rolling example, the expectation is<br \/>\n2*1\/36 + 3*1\/18 + 4*1\/12 + 5*1\/9 + 6*5\/36 + 7*1\/6 + 8*5\/36 + 9*1\/9 +\t10*1\/12 + 11*1\/18 + 12*1\/36 = 7.<\/p>\n<p> Many of the interesting properties that we can study using probability<br \/>\nand statistics come from the probability distributions. We&#8217;ll see more<br \/>\nof that in later posts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The first key concept in probability is called a random variable. Random variables are a key concept &#8211; but since they&#8217;re a key concept of the frequentist school, they are alas, one of the things that bring out more of the Bayesian wars. But the idea of the random variable, and its key position in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[61],"tags":[],"class_list":["post-626","post","type-post","status-publish","format-standard","hentry","category-statistics"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4lzZS-a6","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/626","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/comments?post=626"}],"version-history":[{"count":0,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/626\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/media?parent=626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/categories?post=626"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/tags?post=626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}