Katkat

Simulate Coin Flips to Determine Fairness via Empirical Distribution

GoogleData Scientist · Onsite

Last updated

This question evaluates a candidate's ability to perform simulation-based hypothesis testing by implementing Monte Carlo sampling and computing an empirical two-sided p-value from observed coin-flip counts, emphasizing statistical computation and numerical accuracy.

Scenario

You must test whether a coin is fair by simulation.

Question

Write code that repeatedly simulates n coin flips, records the number of heads, and uses the empirical distribution to compute the two-sided p-value for an observed count of heads without relying on closed-form formulas.

Hints

Focus on efficient Monte Carlo loops or vectorized sampling and correct p-value definition.