I'm using a genetic algorithm to generate a string that produces certain results I map into a line/bar graph. I'm trying to rate how closely the results produced by the genetic string compares to a graph I have produce manually by hand.

Currently I am comparing the graphs be finding the area of difference between the two and getting a percentage representing where it sits between 0 difference and a worst case difference being where they don't overlap at all.

Though I don't feel this rating really represents how closely the shape matches the other. As this is what concerns me the most, as two different results could have the same difference in terms of area but one may be a closer shape then the other, and I would like the one with the closer shape to have a higher rating!

My question is, is there a standard way of rating graphs where i can get a percentage of how closely one matches the other and can you provide the way of going about this?


1 Answer 1


You question is very closely related to this question about differences between distributions.

Have a look at the three answers. That should give you some R code to get started.

BTW, I don't think your question is duplicate. It's a just a question that shares answers.

  • 1
    $\begingroup$ @csgillepsie: there is catch here. The answers about comparing distributions assume the draws from the distributions are iid. From the tone of the questions (.."mapped to line chart") this may not be the case in Tristan's application. That would invalidate all the solutions (k-s, chi-2,...) proposed. $\endgroup$
    – user603
    Oct 5, 2010 at 13:26
  • $\begingroup$ @kwak: Very good spot and something that I missed. Just to clarify it invalidates the k-s and chi-2 solutions, not all all the answers given, i.e. my answer and the answer by Joris still stand. $\endgroup$ Oct 5, 2010 at 13:31
  • $\begingroup$ @kwak @csgillepsie: yeah just to clarify the data i'm dealing with is not iid at all. $\endgroup$
    – Tristan
    Oct 5, 2010 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.