Suppose I'm given a data set consisting of many pairs of $(x,y)$ values which are correlated in some arbitrary complex way. How would I go about 'generating' more pairs of $(x,y)$ coordinates which are distributed in the same way as the base data.

My initial thoughts are to carry out 2D kernel density estimation, and then generate data based on this, however I'm not sure how I would implement the latter part of this (in python).

Otherwise, I was also wondering if there is a different/better technique. Even just the name of such a technique would be appreciated so I can look into it from there. Thanks in advance.

  • 1
    $\begingroup$ By randomly selecting pairs and adding a little bit of noise? $\endgroup$ Commented Sep 30, 2019 at 15:03
  • $\begingroup$ I have tried this however I'm not sure what an appropriate distribution for the noise would be (i.e. its standard deviation etc), also this tends to not work too well when there are sudden changes or a boundary in the underlying density. $\endgroup$
    – Max Hart
    Commented Sep 30, 2019 at 15:14

1 Answer 1


there are two viable ways:

  • just sample rows from the dataset, this should go well for most applications.
  • assume some model for the joint distribution, then draw from it. this is way more complicate than the first choice, so do it only if you really need to. I'm talking about any kind of model, also non-parametric ones like kernel distribution estimation. Point is, whatever the model, you have to make some assumption about it, for instance you have to chose the bandwidth and the kernel for kernel density, and if your data has bounduaries like you said in your comment to your own question, you have to consider it when estimating the model, by default kernel won't respect any bounduary. So there is no one only way to do it, you have to chose the model depending on data.

Also notice that using kernel density and drawing from it is the same as sampling from data and adding noise (gaussian noise if you used gaussian kernel, with st. deviation proportional to kernel bandwidth).

ps: a quite safe choice that is somehow in the middle of these two could be drawing from your data after augmenting it, with some technique based on nearest neighbours like the ones used for inbalanced classes problems in machine learning.


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.