# Generate random variable with given moments

I know first $N$ moments of some distribution. I also know that my distribution is continuous, unimodal and well shaped (it looks like gamma-distribution). Is it possible to:

1. Using some algorithm, generate samples from this distribution, which in limit conditions will have exactly the same moments?

2. Solve this problem analytically?

I understand that until I have an infinite number of moments, this question cannot have a unique solution. I would be happy to have any.

Due to the comments clarification: I don't need to restore original distribution. I need ANY with a given moments.

• How do you define "well shaped" ? – Tim Apr 19 '18 at 7:31
• @Tim It looks like gamma-distribution. I've edited the question accordingly. – zlon Apr 19 '18 at 7:43
• You cannot generate from a distribution for which you only know moments. There even exist cases where the whole sequence of moments is not sufficient to specify the distribution uniquely. – Xi'an Apr 19 '18 at 9:20
• I don't need the unique distribution. I need ANY with given moments. – zlon Apr 19 '18 at 9:21
• If any solution suffices, use your data. – Nick Cox Apr 19 '18 at 11:35

Another paper is http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.106.6130 Its author lists some possible approaches, like maximum entropy methods (Jaynes 1994), a method of obtaining upper and lower bounds on the cumulative distribution function (cdf) using the first $n$ moments (https://www.semanticscholar.org/paper/A-moments-based-distribution-bounding-method-R%C3%A1cz-Tari/cd28087b8ead5c4d5c4eebc2b91e2a4b8caef3f3), but then diced to assume a unimodal distribution and fit to a flexible distribution family, like Pearson family, Johnson family or Generalized Tukey Lambda family. Finally she implements a solution based on fitting first four moments to the Generalized Lambda family.