# Algorithm to generate non normal (discrete and continuous) correlated variables using a correlation matrix

What I am trying to do here is, given a dataset (let's say n observations of N variables), and thus a correlation matrix M that result from said dataset, I would like to write a Python algorithm that generate new "datasets" (i.e N vectors of length n) under the following conditions:

1. The vectors generated would each have respectively the same distribution as the original ones
2. They have to comply with the correlation matrix M

Here is the catch: My variables can be continuous as well as discrete. So far, I've only come across papers where all the variables were continuous. I know similar questions have been posted here, but as far as I know in the latter the variables were all continuous and I have not seen actual algorithm.

While doing some research I've also discovered the notion of copulas but I not sure if I have to resort to them for my purpose.

Thank you for your help, Alex

• Generate data with normal. Then, transform one of them to discrete. Then, combined thme again. I do not use Python, however, the function to transform one column to discrete distribution is qpois() Jul 2, 2020 at 17:58