Tools
Randomness Calculator
Explore investment return randomness with Markov chain analysis of daily, monthly, or annual returns. Compare transition probabilities and Up/Down streak lengths with fair coin flips, using chi-square, runs, and shuffle tests to assess whether the observed sequence is consistent with randomness.
The Markov Chain
A Markov chain is a mathematical model of a sequence of events in which the probability of the next event depends only on the current state — not on anything that came before. Here the states are simply Up and Down months for the selected investment, and the chain measures how likely the market is to stay in its current state or switch. If tomorrow's direction were truly independent of today's, every transition probability would sit near 50% — a fair coin. This calculator computes those probabilities from the actual sequence of Ups and Downs and runs several statistical tests to see whether the market's memory is distinguishable from chance. For the origin, methodology, and surprising applications of Markov chains, please watch this video by Veritasium.
Glossary
- Markov chain
- A model of a system that moves between states where the probability of the next state depends only on the current state — not on the longer history.
- State (Up / Down)
- Each trading day is classified Up if its return exceeds the median return of the selected period, or Down if it falls below.
- Median return
- The middle daily return of the selected period — half of the days are above it, half below. Splitting at the median makes Up and Down equally likely, like the two sides of a fair coin.
- Median / mean computed over
- The selected window: calculates the median or mean using only returns between your Starting and Ending dates. Changing those dates can change the threshold used to classify returns as Up or Down. Full history: calculates the threshold using all available history loaded for the selected investment and return frequency, including returns outside your chosen dates. This keeps a common threshold when comparing different date ranges with the same data settings. In both cases, the transitions and statistical tests still analyze only your selected date range. Switching scope can change the Up/Down classifications and results without changing the selected dates.
- Transition probability
- P(next | current): the observed likelihood of moving from yesterday’s state to today’s. For example, P(Up | Down) is the share of Down days that were followed by an Up day.
- Tie
- A day whose return exactly equals the median. The tie rule decides whether it counts as Up (the default), Down, or is excluded with the transition bridged from the prior day to the next.
- Significance level (α)
- The evidence bar for declaring memory: a test flags memory when its p-value falls below α. Raising α flags weaker evidence (and mislabels a truly fair coin more often); lowering it demands stronger proof. A detection at level α corresponds to 100% − α confidence. Currently set to 5%: tests fail when p < 0.05 (|z| > 1.96).
- Wilson confidence interval
- A range around each measured probability expressing statistical uncertainty at the chosen confidence level. If 50% lies inside the interval, the measured value is consistent with a fair coin.
- Chi-square (χ²) test
- Compares the observed transition counts with the counts a memoryless fair coin would produce. A p-value at or above the chosen significance level (α) means no statistically detectable memory.
- Run (streak) length
- The number of days in a row spent in the same state before it flips. A run of 1 is a single day flanked by the opposite state on both sides. A fair coin halves the expected count with each extra day — shown on the runs chart as the Coin: Heads and Coin: Tails bars beside the observed Up and Down runs.
- Fair coin (memoryless)
- A process where each outcome is 50/50 and independent of all previous outcomes. It is the benchmark the market’s Up/Down sequence is tested against.
- Threshold (median / mean / zero)
- The dividing line between Up and Down. The median (default) splits the days 50/50 like a fair coin; the mean is the average return; zero classifies every positive day as Up — the intuitive reading, but it makes Up days more common than Down days in a rising market.
- Find longest 50/50 period
- Sets the date range whose transition counts are nearest 25% each and whose P(next | current) values are nearest 50% — the longest range that rounds to exactly 50.00% wins.
- Find longest random period
- Sets the longest date range in which the fair coin (χ²), runs (Wald–Wolfowitz), and shuffle tests all pass at the chosen significance level (α), using the current threshold, tie rule, and scope. When several ranges tie for longest, the most recent wins. The shuffle test is randomized, so its p-value can differ slightly between runs.
- Runs test (Wald–Wolfowitz)
- Counts how many maximal same-state streaks (runs) the sequence contains and compares that with the number a random ordering would produce. Too few runs means streaky (trending) behavior; too many means zig-zagging. A p-value at or above the significance level means the ordering is consistent with randomness.
- Rolling runs test
- The Wald–Wolfowitz z-score recomputed over a sliding window that advances one period at a time. A z-score below the negative critical value means that window was streakier (fewer runs) than a fair coin at the chosen confidence; above the positive critical value means it was choppier (more runs). Inside the shaded band, the ordering is consistent with randomness — one full-period verdict can hide episodes of each.
- Higher-order Markov test
- Instead of conditioning on yesterday alone, condition on the last 2 or 3 states (e.g. Up-Up vs Down-Up) and test whether any longer pattern predicts the next move better than chance. A p-value at or above the significance level means even the longer memory adds no predictive power.
- Longest streak context
- The longest observed run of consecutive Up (or Down) periods, compared with the exact probability that a fair coin flipped the same number of times produces a streak at least that long. Long streaks feel meaningful but are usually well within what pure chance produces.
- Conditional returns
- The average next-period return following an Up period versus following a Down period. If yesterday’s direction carried useful information, these averages would differ significantly; a Welch t-test p-value at or above the significance level means knowing yesterday’s direction would not have improved expected returns.
- Shuffle (permutation) test
- The actual Up/Down sequence is reshuffled 1,000 times, destroying any day-to-day ordering while keeping the same mix of Ups and Downs. The p-value is the share of reshuffles whose transition structure is at least as extreme as the real sequence — at or above the significance level means the real ordering is indistinguishable from a random shuffle of itself.
Disclosures
The data provided in all charts and calculations on this page is hypothetical backtested performance and is not actual client performance. IFA Index Portfolios and Fund Portfolios are shown net of IFA's maximum annual advisory fee of 0.9% and the deduction of underlying fund fees, and include reinvestment of dividends and capital gains. All other data, including the IFA Indexes and Funds, does not reflect a deduction of IFA advisory fees. None of the data reflects transaction costs or taxes, which if included, would lower performance. See more important disclosures.
Index Portfolio S2B2 is the current default portfolio for new clients at IFA. Fund Portfolio S1B1 refer to various fund allocations of stock and bond funds. Please contact an IFA Wealth Advisor for more details on fund options.
The median is one of the three types of averages, along with the mean and the mode. The median return for IFA Indexes, IFA Index Portfolios, Fund Portfolios, and Funds for any time horizon (daily, monthly, or annual) is the middle value when returns are sorted from high to low, splitting the historical data into 50% above and 50% below the median. Observed coin flips have a 50-50 chance of landing on heads (H) or tails (T). A fair coin and the actual returns of the IFA Index Portfolios, IFA Indexes, Fund Portfolios, and Funds have had a 50-50 chance of Up (U) or Down (D) relative to the median return, as shown on the runs chart above. The fair-coin comparisons are computed from the expected behavior of an unbiased coin and are purely for entertainment purposes. Coin comparisons are made against actual daily, monthly, or annual returns of IFA Index Portfolios, IFA Indexes, Fund Portfolios, or Funds relative to the median return over the selected period. See IFA Indexes descriptions at ifa.com/disclosures/index-data and Fund descriptions at ifa.com/disclosures/fund-data. This tool is for entertainment and educational use only and is not designed for or capable of making financial, market, or investment predictions. No data from the tool's use is collected or stored.
For HYPOTHETICAL back-tested performance data shown on this page, see ifabt.com. IFA Index Portfolios and Fund Portfolios are labeled with numbers that refer to the percentage of stock indexes in the asset allocation, as opposed to the allocation of bond indexes. For example, an IFA Index Portfolio 90 is 90% IFA stock indexes and 10% IFA bond indexes. For more, go to indexdescriptions.com. The HYPOTHETICAL back-tested performance of the IFA Index Portfolios and Fund Portfolios was achieved with the benefit of hindsight; it does not represent actual investment strategies for the entire period; and it does not reflect the impact that economic and market factors may have had on the advisor's decision making if the advisor were actually managing client money during the period shown. The IFA Index Portfolios were created by IFA in 2000. The Fund Portfolios were created by IFA in 2026. Past performance does not guarantee future results. Performance figures may contain both live and HYPOTHETICAL back-tested data. All data, including performance data, is provided for illustrative purposes only; it does not represent actual performance of any client portfolio or account and it should not be interpreted as an indication of such performance.
