This function selects an appropriate bandwidth `sigma`

for the kernel estimator of point process intensity
computed by `density.ppp`

.

The bandwidth \(\sigma\) is chosen to
minimise the discrepancy between the area of the observation window and the
sum of reciprocal estimated intensity values at the points of the point process
$$
\mbox{CvL}(\sigma) =
(|W| - \sum_i 1/\hat\lambda(x_i))^2
$$
where the sum is taken over all the data points \(x_i\),
and where \(\hat\lambda(x_i)\) is the
kernel-smoothing estimate of the intensity at
\(x_i\) with smoothing bandwidth \(\sigma\).

The value of \(\mbox{CvL}(\sigma)\) is computed
directly, using `density.ppp`

,
for `ns`

different values of \(\sigma\)
between `srange[1]`

and `srange[2]`

.

The result is a numerical value giving the selected bandwidth.
The result also belongs to the class `"bw.optim"`

which can be plotted to show the bandwidth selection criterion
as a function of `sigma`

.