by solving our maximization problem with a Lagrangian. Again, the matched filter endeavors to maximize the output signal-to-noise ratio () of a filtered deterministic signal in stochastic additive noise. The observed sequence, again, is with the noise covariance matrix, The signal-to-noise ratio is where and . Evaluating the expression in the numerator, we have and in the denominator, The signal-to-noise ratio becomes If we now constrain the denominator to be 1, the problem of maximizing is reduced to maximizing the numerator. We can then formulate the problem using a Lagrange multiplier: which we recognize as a generalized eigenvalue problem Since is of unit rank, it has only one nonzero eigenvalue. It can be shown that this eigenvalue equals yielding the following optimal matched filter This is the same result found in the previous subsection. Interpretation as a least-squares estimator Derivation Matched filtering can also be interpreted as a least-squares estimator for the optimal location and scaling of a given model or template. Once again, let the observed sequence be defined as where is uncorrelated zero mean noise. The signal is assumed to be a scaled and shifted version of a known model sequence : We want to find optimal estimates and for the unknown shift and scaling by minimizing the least-squares residual between the observed sequence and a "probing sequence" : The appropriate will later turn out to be the matched filter, but is as yet unspecified. Expanding and the square within the sum yields The first term in brackets is a constant (since the observed signal is given) and has no influence on the optimal solution. The last term has constant expected value because the noise is uncorrelated and has zero mean. We can therefore drop both terms from the optimization. After reversing the sign, we obtain the equivalent optimization problem Setting the derivative w.r.t. to zero gives an analytic solution for : Inserting this into our objective function yields a reduced maximization problem for just : The numerator can be upper-bounded by means of the Cauchy–Schwarz inequality: The optimization problem assumes its maximum when equality holds in this expression. According to the properties of the Cauchy–Schwarz inequality, this is only possible when for arbitrary non-zero constants or , and the optimal solution is obtained at as desired. Thus, our "probing sequence" must be proportional to the signal model , and the convenient choice yields the matched filter Note