1

I would like to calculate the total variation distance(TVD) between two continuous probability distributions. I would like to point out that while there are two relevant questions(see here and here), they are both working with discrete distributions.

For those not familiar with TVD,

Informally, this is the largest possible difference between the probabilities that the two probability distributions can assign to the same event.

as it is described in the respective Wikipedia page. In the case of continuous distributions, TVD is equal with half the integral of the absolute difference between the two (since I cannot add math notation see this for a proof and for the notation).

So far, I wasn't able to find a tool for my job in Python. I would be interested in one if exists. Also, while I have no experience in R, I understand that is commonly used for such tasks so I would be interested in one as well (TVD calculation is the final step of my algorithm so I guess it won't be hard to read some data from a file, do the calculation and print a number even if I am completely new to R).

I would like to add that I am mainly interesting in normal distributions so a tool strictly for those is more than welcomed.

If no such tools exist, then any help adapting answers from this question to use the builtin probability functions will be of great help as well.

Thank you in advance.

cgss
  • 233
  • 2
  • 10
  • Looks like the functin `TotalVarDist` from the `distrEx` package does this calculation. – G5W Aug 15 '20 at 14:11
  • @G5W I think you are talking about [this](https://www.rdocumentation.org/packages/distrEx/versions/2.8.0/topics/TotalVarDist). But if I understand correctly it is only for 1D distributions? – cgss Aug 15 '20 at 14:45
  • Yes That is what I meant and yes, that is 1D only. – G5W Aug 15 '20 at 14:49
  • @G5W It appears that there is a ND as well but isn't builtin(or something like that, I am not sure yet) – cgss Aug 15 '20 at 14:59

0 Answers0