← Back to Problems
The Mean-Reverting Spread
Easy standard Stochastic Calculus
Time limit: 2 s per test  ·  Memory: 256 MB

A pairs trading desk watches the spread X_t between two cointegrated stocks. The spread follows an Ornstein-Uhlenbeck process

dX_t = theta * (mu - X_t) dt + sigma dW_t

starting at X_0 = x_0.

Compute three quantities for the spread at time T: its expectation, its variance, and the probability that it is above the level c.

Input

Six numbers theta, mu, sigma, x_0, c and T, each with at most 6 digits after the decimal point.

Output

Three real numbers on one line: E[X_T], Var(X_T) and P(X_T > c), each with absolute or relative error at most 1e-9.

Constraints

0.01 <= theta <= 10

-10 <= mu, x_0, c <= 10

0.01 <= sigma <= 5

0.001 <= T <= 50

Scoring

This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.

Numeric answers are accepted if they are within an absolute tolerance of 1e-09 or a relative tolerance of 1e-09 of the expected value.

Examples

input
1 0 1 1 0 1
output
3.678794411714e-01 4.323323583817e-01 7.120882208899e-01
input
2 1.5 0.5 -1 1.5 10
output
1.499999994847e+00 6.250000000000e-02 4.999999917772e-01
Python 3.13 i Execution environment Isolated microVM · 1 vCPU · no internet access Time and memory limits are set per problem Available packages numpy 2.5.0scipy 1.18.0pandas 3.0.0scikit-learn 1.9.0statsmodels 0.15.0cvxpy 1.9.2