Statistics – Fit Sinusoidal Function to Three Points

statistics

I have three data points measured at $-30$, $0$, and $30$ degrees, respectively. I would like to fit these points to a sinusoidal function of the form:

$$f(\theta)≈A\sin(\theta + B) + C$$

Is this possible? If so, what would be the best approach?

I saw a similar post here, however this assumed that the measurements were $90$ degrees apart which helps to simplify things greatly.

Thanks,

Best Answer

Yes, of course it is possible. Proceed in the following way:

Let the three values at $-30,0,30$ be $y_1,y_2,y_3$ repec. Then you get three equations in $A,B,C$ \begin{equation} \begin{split} A\sin (-30+B)+C=&y_1\\ A\sin (B)+C=&y_2\\ A\sin (30+B)+C=&y_3 \end{split} \end{equation} From the first and last equation, after some trigonometric manipulation you get $$2A\sin B \cos 30=y_3-y_1\Rightarrow A\sin B=\frac{y_3-y_1}{\sqrt{3}}$$

Then from second equation you get $$C=y_2-\frac{y_3-y_1}{\sqrt{3}}$$

Now from the last equation you get after using the $\sin(A+B)$ expansion formula $$A\sin B \cos 30+A\cos B \sin 30=y_1\\ \Rightarrow \frac{(y_3-y_1)}{2}+\frac{A\cos B}{2}+y_2-\frac{y_3-y_1}{\sqrt{3}}=y_3$$ So you can find $A\cos B$ from here. So, now you can use $\displaystyle \sin^2B+\cos^2 B=1$ to get $$A=\sqrt{(A\sin B)^2+(A\cos B)^2}$$ Once you get $A$, then you can get $B$ from $$B=\tan^{-1} \left(\frac{A\sin B}{A \cos B}\right)$$ restricting $B$ in $[-\pi/2,\pi/2]$, you can get $B$.

Note: This procedure is valid for arbitrary angles, they need not be necessarily $30^\circ$ apart.

Related Question