|I have a light that changes from on to off or from off to on when I clap twice. The light's sensor
samples the noise level in the room
at short intervals and it triggers the light to change whenever it
detects a low noise level followed by exactly 2 high noise levels followed by a
low noise level.
"High" or "low" is based on a threshold noise level. When the sampled noise level is as high or higher than the threshold level, the noise level is classified as "high"; otherwise it is classified as "low". I have a int background that is a typical sequence of sensor readings when normal activity is taking place. I want software that will choose the threshold value so that it has the following properties:
Create a class ClapLight that contains a method threshold that is given the int background and that returns the desired threshold value.
|-||background will contain between 4 and 50 elements inclusive.|
|-||Each element of background will be between 0 and 1000 inclusive.|