Kernel Density
To conclude the chapter, we will discuss using kernel density estimates to perform outlier detection on a set of blood samples. Kernel density estimation provides a natural way to test whether a particular set of blood results are anomalous, even without having specialized knowledge of the particular blood test being used or even of medicine in general.
Suppose that you are working at a doctor's office and your boss asks you to do a new type of blood test on patients. Your boss wants to know if any of the patients have anomalous test results. However, you are not familiar with this new blood test and you do not know what normal and anomalous results are supposed to look like. All you have is a record of previous blood tests that your boss assures you are from normal patients. Suppose that these tests had the following results:
normal_results<-c(100,95,106,92,109,190,210,201,198)
Now suppose that your boss wants you to find anomalies (if any) in the following new blood test...