I've got to optimize the following function with respect to $\phi$:
$q(\phi, x) = \frac{1}{n} \sum_{i=1}^{n}{H(y_i)}$
where
$y_i = k - \phi l - x_i$
and $H(.)$ denotes the Heaviside function. $k$ and $l$ are constants, and $x$ follows either (1) a continuous uniform distribution or (2) a normal distribution. This is part of a quite standard programming problem but I'm a little stuck with finding the optimal $\phi$
I'm sure this is a totally simple question but I can't quite figure it out... any help is greatly appreciated...