Study guides · Introductory

Random variables and distributions: behavior beyond the average

Learn discrete distributions, expectation, variance, and conditional probability using latency and failure examples. Work through concrete cases and separate mathematical assumptions from implementation checks.

Ask Logeia about this articleTry the three questionsReview your answers

Updated

On this page
  1. Map uncertain outcomes to numbers
  2. Calculate an expectation and interpret it carefully
  3. Expose an independence assumption
  4. Describe spread and revisit the model
  5. Condition on the operating context
  6. Compute variance with units
  7. Specify the quantile convention
  8. Reverse a condition carefully
  9. Revisit the dependence behind retry arithmetic
  10. Ask Logeia about this articleCheck your understanding

Map uncertain outcomes to numbers

A random variable assigns a numerical value to an outcome. The number of failed requests in two attempts can be zero, one, or two. Its distribution specifies the probability of each possible value. For a discrete distribution, all probabilities are nonnegative and their sum is one. A histogram of observations estimates such behavior, but it does not guarantee that unobserved operating conditions will follow the same distribution.

Calculate an expectation and interpret it carefully

Suppose a request takes one millisecond with probability 0.9 and 101 milliseconds with probability 0.1. Its expected latency is eleven milliseconds. Neither possible outcome actually lasts eleven milliseconds. The expectation is a probability-weighted average, not a promise about an individual request, a median, or an upper bound. This example explains why a service can have a modest average while some users still experience noticeably slow responses.

Expose an independence assumption

If two request failures each have probability 0.1 and are independent, the probability that both fail is 0.01. Shared infrastructure can invalidate that assumption: a broken connection or overloaded server may make failures occur together. In general, the probability of A and B equals the probability of A multiplied by the probability of B given A. Writing the conditional probability explicitly shows exactly where independence would allow a simplification.

Describe spread and revisit the model

Two distributions can have the same mean and very different variation. Variance summarizes the expected squared distance from the mean; it helps distinguish stable observations from widely scattered ones. It still does not determine the entire shape of a distribution. Inspect quantiles and separate materially different workloads when studying response times. A model fitted during light traffic may be misleading during saturation. Treat independence, stationarity, and the chosen population as assumptions to investigate rather than properties automatically supplied by a probability formula.

Condition on the operating context

Combining normal operation and an outage into one average can produce a value typical of neither situation. Examine distributions conditioned on a relevant context, such as dependency health or traffic level, when looking for clustered failures. A small sample still leaves substantial estimation uncertainty. Do not turn a numerically small modeled probability into a claim that an event cannot occur. Record the population and conditions from which the estimate was obtained.

Compute variance with units

The two-point latency distribution has mean 11 ms. Its variance is(1−11)²×0.9+(101−11)²×0.1=900 square milliseconds, and its standard deviation is 30 ms. Squaring changes the unit; taking a square root restores the original unit. Adding one standard deviation to the mean does not produce a maximum possible latency. This distribution is not normal, so familiar normal-distribution coverage rules cannot be imported merely because a mean and standard deviation are available. If the operational question concerns the probability of a slow response, consult the distribution or a relevant quantile directly. Summary statistics answer particular questions and should not replace the information required by a different decision.

Specify the quantile convention

Define the p-quantile here as the smallest value whose cumulative probability is at least p. Cumulative probability reaches 0.9 at 1 ms and 1 at 101 ms. The median and 90th percentile are therefore 1 ms, while the 95th percentile is 101 ms. The mean alone hides this jump. Software estimating sample quantiles can use different interpolation conventions between ordered observations, particularly noticeable with small samples. Before comparing dashboards, align their definitions and input windows rather than assuming any disagreement indicates a service change. Recording the number of requests exceeding an explicit latency threshold can complement a percentile. It makes the counted event clear and can reveal a changing failure fraction that a coarse summary otherwise obscures.

Reverse a condition carefully

Consider ten thousand monitored cases, of which one hundred genuinely have a fault. A detector flags ninety faulty cases and also flags ninety-nine of the 9,900 healthy cases. Sensitivity is 90/100=90 percent, but the probability of a fault given a flag is 90/189, approximately 48 percent. The denominators describe different populations. A high detection rate does not imply that nearly every alert represents a real fault when faults are uncommon. These are illustrative counts rather than observations from a particular service. An operational evaluation also needs a fault-labeling rule, the prevalence in the target population, false-alarm costs, missed-event costs and available investigation capacity. State the conditioning event before interpreting any reported percentage.

Revisit the dependence behind retry arithmetic

Two attempts do not have a joint failure probability of 0.01 merely because each marginal failure probability is 0.1. A common outage can affect both. In a model where a link is down with probability 0.02 and that event makes both attempts fail, the joint failure probability is already at least 0.02 from that shared cause alone. Marginal rates do not determine the overlap of failure events. Waiting before retrying or selecting another dependency can change which conditions are shared, but neither automatically establishes independence. Trace common power, routing and authentication dependencies as well. A probability calculation is useful when its assumptions describe the proposed mechanism, rather than when convenient independence is added after the fact.

Reading and practice are recorded separately in this browser, for each language.

Learn this in order

Prepare for AI systems · STEP 10

Choose a learning path