View the code
This is a correlation-based optimal detector for a signal known exactly see Green & Swets (1966) for more details.