title: How to compare two Probability Density Functions?
body: <p>I have two Probability Density Functions and I want to know if their distributions are similar or not. I know that KS test in R can do this, but when I run the code, an error occurs. Thanks for any help.</p>
  
  <pre><code>set.seed(100)
  a=density(sample(x=1:30,size = 30,replace = T))
  b=density(sample(x=1:40,size = 35,replace = T))
  plot(a)
  lines(b)
  
  ks.test(a,b)
  Error in ks.test(a, b) : 
   'y' must be numeric or a function or a string naming a valid function
  </code></pre>