How to calculate the width of a variance

34 Views Asked by At

Short version

I have a series of results that sit within clear upper and lower bounds relative to the starting value. I do not know how to find those bounds (and thus the width of the band). I would like answers that will help me find them.

Long version

I have been doing some recreation mathematics. I found a fun set of rules and wrote a script to get me all the answers for integers from 1 to whatever number I asked for. I had these values save to a database as the larger numbers were a bit intensive to work out.

The next step I took was to export my answers to CSV and imported them into a spreadsheet. I add a column where I took the derived value from the original integer. I then charted the results. Which is when I spotted the pattern. All the answers lay on a straight line plus or minus some value.

enter image description here

I pulled a bigger sample and did the same again:

enter image description here

As you can see, I am very confident that the results fall within two bounds on a straight line. How do I calculate the width of the line?

2

There are 2 best solutions below

0
On

Let $M_t$ and $m_t$ be respectively the upper and the lower bounds and $X_t$ be the data at the date $t$.

For $t$ going from $1$ to $T$, you can compute $$M_t = \max_{1\leq s\leq t}X_t\,\quad m_t = \min_{1\leq s \leq t}\{X_t, X_t\notin \{m_1,m_2,\dots,m_{t-1} \}\}$$

0
On

Let's assume you are correct in that there exists a line $y=mx + b$ such that the set of all your sequence values $S \subset \mathbb{R^2}$ fall within some distance from this line.

This means we are hypothesizing the following:

$$\exists (m,b,\eta) \in \mathbb{R}^3_+: s_n \in \{(x,y) \in \mathbb{R^2}: |y-mx+b|\leq \eta\} \; \forall s_n \in S$$ $$ \text{ and } |\{s_i \in S:s_y = ms_x + b + \eta \}| \geq 1$$ $$ \text{ and } |\{s_i \in S:s_y = ms_x + b - \eta \}| \geq 1$$

In this case $(m,b,\eta)$ is the solution to the following linear programming problem:


$ \text{minimize} \;\;\eta$

s.t.

$y_i-mx_i+b \geq -\eta\;\forall i$

$y_i-mx_i+b \leq \eta\;\forall i$

$\eta,m,b \geq 0$


I gave this a try on excel with simulated data for the band $y_i = x_i +(2U-1)$ where $U \sim \text{Unif}(0,1)$ just to test it. Even with being limited to 100 points, I got pretty decent results: enter image description here