An experiment whose result is decided at random — like flipping a coin or rolling a die — is called a trial. A number that pins down the result of this trial is exactly a random variable X. For example, the number that comes up on a single die roll, or the number of heads when a coin is flipped three times, are both random variables.
A table that pairs up each value a random variable X can take with the probability of that value is called a probability distribution table. For example, consider the random variable that's 1 if a coin lands heads and 0 if tails — the probability of X=1 and the probability of X=0 are each 1/2. All the probabilities in a probability distribution table must always add up to 1 — because together they account for every possible outcome, with nothing left out.
If a random variable X can take the values x1, x2, ..., xn, with respective probabilities p1, p2, ..., pn, then the expected value E(X) is found by multiplying each value by its probability and adding them all up. E(X) = x1p1 + x2p2 + ... + xnpn. This isn't the "ordinary average" you get by simply adding values and dividing by the count — it's a weighted average that gives more weight to values that happen more often, and less weight to values that happen rarely.
The easiest way to understand this is with a scale. Imagine placing the values a random variable can take onto a scale, with a heavier weight for whichever value has a larger probability of occurring. The point where this scale balances perfectly level is exactly the expected value. Because the pull toward the side with larger probability is stronger, the balance point always gets dragged closer to the value with higher probability.
Expected value really proves its worth when judging whether a game is "fair." Consider a game where rolling a die that lands on 6 wins you a prize, and anything else wins nothing. If the prize is 600, the expected value is E(X) = 600×(1/6) + 0×(5/6) = 100. Set the entry fee to exactly 100, and over a huge number of repeats, the money won and the money paid in entry fees average out to be equal — that's exactly a "fair entry fee."
If the entry fee is lower than the expected value, the game favors the player; if it's higher, the game favors the house. The reason casino games and lotteries ultimately benefit the operator is that the entry fee (or ticket price) is set just slightly higher than the expected value. You might win a round or two through luck, but as a huge number of people play a huge number of times, the results eventually converge to something close to the expected value.
On the activity page, you can change two values A, B and their respective probabilities with sliders and watch the scale's balance point move in real time, and on the dice prize game tab, you can adjust the prize and entry fee yourself and check whether the game favors the player, favors the house, or is fair.