Can These Three Correlations Exist?
Updated
Problem statement
Three random variables X, Y and Z each have a positive, finite variance. Someone claims that their correlations are:
corr(X, Y) = xy / 100corr(Y, Z) = yz / 100corr(X, Z) = xz / 100
Return true if some three random variables can have exactly these three correlations at the same time. Return false if no such variables exist.
The inputs are whole numbers, so the three correlations are exact. A set of correlations that sits exactly on the edge of what is possible counts as possible.
Function
correlationsPossible(xy: int, yz: int, xz: int) → booleanExamples
Example 1
xy = 90yz = 90xz = 50return = falseThis is the interview case. Write the correlations in a matrix with 1 on the diagonal, in the order X, Y, Z:
1.0 0.9 0.5
0.9 1.0 0.9
0.5 0.9 1.0A real correlation matrix never has a negative determinant. Here the determinant is 1 - 0.81 - 0.81 - 0.25 + 2 × 0.9 × 0.9 × 0.5 = -0.06, so the answer is false.
In plain words: X and Z are both very close to Y, so they must also be fairly close to each other. Their correlation has to be at least 0.62.
Example 2
xy = 10yz = 80xz = 70return = falseEach correlation on its own is fine, but the three together are not. The determinant is 1 - 0.01 - 0.64 - 0.49 + 2 × 0.1 × 0.8 × 0.7 = -0.028, which is negative, so the answer is false.
Example 3
xy = 90yz = 90xz = 62return = trueThe determinant is 1 - 0.81 - 0.81 - 0.3844 + 2 × 0.9 × 0.9 × 0.62 = 0, so these correlations sit exactly on the edge and the answer is true.
Here is one way to get them. Let Y and W be independent with variance 1, and set X = 0.9 Y + s W and Z = 0.9 Y - s W with s = sqrt(0.19). Then X and Z have variance 0.81 + 0.19 = 1, each has correlation 0.9 with Y, and corr(X, Z) = 0.81 - 0.19 = 0.62.
Constraints
-100 <= xy, yz, xz <= 100
More Susquehanna International Group (SIG) Phone Screen questions
- Dice Sum That Is a Multiple of mPHONE SCREEN · Seen Nov 2026
- Find Median from Data StreamPHONE SCREEN · Seen Nov 2026
- Painting Arcs to Nearest Neighbors on a CirclePHONE SCREEN · Seen Sep 2026
- Filter Movies by Inclusive Year RangePHONE SCREEN · Seen Jul 2026
- Best Single Reroll for Five DicePHONE SCREEN · Seen Feb 2026
- Catching the Bus to the MoviePHONE SCREEN · Seen Jan 2026
- Two Dice Summing to a TargetPHONE SCREEN · Seen Jan 2026
- Median of Uniform Draws in an IntervalPHONE SCREEN · Seen Oct 2025
- One Number Is the Average of the Other TwoPHONE SCREEN · Seen Jun 2025
- Which Coin Pattern Shows Up FirstPHONE SCREEN · Seen May 2025
Similar questions at other companies
- Integers With Multiple Sum of Two CubesCharta Health · PHONE SCREEN · ONSITE INTERVIEWCharta Health interview questions
- Dice-Walk Winning ProbabilityGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Logistic Regression with Gradient DescentYahoo · PHONE SCREENYahoo interview questions
- Evaluate an Arithmetic Expression Written in WordsBrex · PHONE SCREEN
- Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
- Integer to English Words in USD and INR StylesVeeam · PHONE SCREEN
- Adaptive Calibration ErrorOpenAI · PHONE SCREENOpenAI interview questions
- Sum of Smallest Non-DivisorsThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
- Square Root FunctionCitadel · PHONE SCREENCitadel interview questions
- Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions