# Bearing Estimation for Indoor Localization Systems Using Planar Circular Photodiode Arrays
## 2 The Planar Circular Photodiode Array (PCPA)
### Least-Squares Estimator  
The least-squares angle estimate is reviewed here based on the results of [12] and [13]. The incoming light intensities from a particular light source are measured and the \(N\)-element measurement vector denoted with \(\Psi\), as follows:  
\[\Psi=[\Psi_{0},\ \Psi_{1},\ \ldots\Psi_{N-1}]^{T}, \tag{1}\]  
where \(\Psi_{i}\) is the measured light intensity in channel \(i\) and \((. )^{T}\) is the transpose operator. A calibration matrix \(R_{N\times M}\) is created where \(N\) is the number of channels in the PCPA and \(M\) is the number of calibration measurements. Row \(n\) of \(R\) corresponds to a particular PCPA channel \(n\), and the values in this row contain the measured channel sensitivity values, sampled in \(M\) equidistant angles \(\varphi_{m},0\leq m<M-1\), where  
\[\varphi_{m}=m\cdot 360/M. \tag{2}\]  
Notice that Figure 1 contains such a normalized measurement for one channel. See Section 4.1 for further multichannel measurement examples. On the other hand, columns of \(R\) correspond to directions \(\varphi_{m}\), as follows:  
\[R=\left[ \begin{array}{cccc}&R_{0}&R_{1}&\ldots&R_{M-1}\\ \end{array} \right], \tag{3}\]  
where column \(R_{m}\) contains intensity values \(r_{n,m}\) for each channel \(n\), measured using a light source with bearing \(\varphi_{m}\) :  
\[R_{m}=\left[ \begin{array}{cccc}&r_{0,m}&r_{1,m}&\ldots&r_{N-1,m}\\ \end{array} \right]^{T} \tag{4}\]  
The least squares bearing estimate will be the angle \(\varphi_{m}\) for which the shape of \(R_{m}\) is closest to the shape of \(\Psi\), in the least squares sense. Recall that the measured light intensity depends not only on the  
Figure 2: The bearing measurement process using planar circular photodiode array (PCPA). Different colors represent different channels; left: sensitivity curves, middle: measured amplitudes. bearing but also on the distance between the light source and the sensor, and also on the power of the light source. Thus we use a scaling in order to define the distance between \(R_{m}\) and \(\Psi\), as follows:  
\[E_{m}(\lambda)=\parallel R_{m}-\lambda\Psi\parallel_{2}. \tag{5}\]  
In (5) \(E_{m}\) is the squared error between the calibration vector \(R_{m}\) and the measured vector \(\Psi\), and \(\lambda\) is the unknown scaling factor. The least squares cost function for angle \(\varphi_{m}\) is defined as the smallest possible value of \(E_{m}(\lambda)\), as follows:  
\[e_{m}=\underset{\lambda}{\min}E_{m}(\lambda) \tag{6}\]  
As a first step, we determine the optimal value for \(\lambda\), given the value of \(m\). From (2) and (3) it directly follows that  
\[E_{m}(\lambda)=\sum_{n=0}^{N-1}\left(r_{n,m}-\lambda\Psi_{n}\right)^{2}=\sum_{ n=0}^{N-1}\left(r_{n,m}^{2}+\left(\lambda\Psi_{n}\right)^{2}-2\lambda r_{n,m} \Psi_{n}\right) \tag{7}\]  
At the minimum of \(E_{m}\) the derivative \(\frac{dE_{m}}{d\lambda}\) is zero:  
\[\frac{dE_{m}}{d\lambda}=\frac{d}{d\lambda}\left(\sum_{n=0}^{N-1}r_{n,m}^{2}+ \lambda^{2}\sum_{n=0}^{N-1}(\Psi_{n})^{2}-2\lambda\sum_{n=0}^{N-1}r_{n,m}\Psi _{n}\right)=2\lambda\sum_{n=0}^{N-1}(\Psi_{n})^{2}-2\sum_{n=0}^{N-1}r_{n,m} \Psi_{n}=0 \tag{8}\]  
From (8), the optimum value of \(\lambda_{m}\) is the following:  
\[\lambda_{m}=\frac{\sum_{n=0}^{N-1}r_{n,m}\Psi_{n}}{\sum_{n=0}^{N-1}\left(\Psi_ {n}\right)^{2}}=\frac{(R_{m})^{T}\Psi}{\Psi^{T}\Psi}, \tag{9}\]  
Using the optimal value of \(\lambda_{m}\), the cost function (6) now can be calculated as follows:  
\[e_{m}=\underset{\lambda}{\min}E_{m}(\lambda)=E_{m}(\lambda_{m})=\parallel R_ {m}-\lambda_{m}\Psi\parallel_{2}. \tag{10}\]  
Notice that each index \(m\) corresponds to bearing \(\varphi_{m}\). Thus index \(m_{opt}\), for which the cost function (9) is minimal, defines the best bearing estimate. The optimal bearing index \(m_{opt}\) is the following:  
\[m_{opt}=\underset{m}{\arg\min}\ e_{m}, \tag{11}\]  
and, using (2), is the bearing estimate is  
\[\hat{\varphi}=\varphi_{m_{0}}=m_{0}.\frac{360}{M}. \tag{12}\]  
Notices:  
1.