# Getting dataset whose cumulants match user-provided values?

I'm interested in getting list of numbers whose cumulants match user-specified list of values. Below is an example that works for list of length 2, but I'm interested in generalizing it to higher cumulants. I have a feeling something under Combinatorica set of functionality may help with this, any ideas?

genData[cumulants_, n_] := (
data = RandomReal[{-1, 1}, n];
data = data - Cumulant[data, 1];
data = data/Sqrt[Cumulant[data, 2]];
data = data*Sqrt[cumulants[[2]]];
data = data + cumulants[[1]];
obtainedCumulants =
Table[Cumulant[data, i], {i, 1, Length@cumulants}];
Print["error=", Norm[obtainedCumulants - cumulants]];
data
);
genData[{1, 3}, 3]


If you are interested in determining $$k$$ observations that produce a specific set of $$k$$ sample cumulants, then the following should work:

(* Set the first 3 cumulants *)
k = {5, 2, 1};

(* Find observations for which the sample cumulants match k *)
n = Length[k];
NSolve[Table[k[[i]] == Cumulant[Table[x[j], {j, n}], i], {i, n}], Table[x[j], {j, n}]]

(* {{x[1] -> 4.6527, x[2] -> 3.46791, x[3] -> 6.87939},
{x[1] -> 6.87939, x[2] -> 3.46791, x[3] -> 4.6527},
{x[1] -> 3.46791, x[2] -> 4.6527, x[3] -> 6.87939},
{x[1] -> 6.87939, x[2] -> 4.6527, x[3] -> 3.46791},
{x[1] -> 3.46791, x[2] -> 6.87939, x[3] -> 4.6527},
{x[1] -> 4.6527, x[2] -> 6.87939, x[3] -> 3.46791}} *)


If $$k$$ is less than the number of desired observations, then you're likely to have an infinite number of solutions.

• What if the number of observations is not equal to the number of given cumulants? Commented Dec 14, 2019 at 10:55
• @yarchick Good question. I await the OP to clarify. Not only what is needed but "why" it is needed would be helpful. My limited imagination is not coming up with any practical reason to do so (other than maybe simple textbook examples) but I certainly could be wrong about that.
– JimB
Commented Dec 14, 2019 at 14:32
• Thanks for the suggestion, I was indeed looking for solution for general n. The reason is to check how my gradient descent algorithms are affected by higher order moments in the data, so I need to generate some datasets with this properties wolframcloud.com/obj/yaroslavvb/newton/… Commented Dec 14, 2019 at 19:31
• Another example, NormalDistribution has following cumulants {0,1,0,0,0,...}. It seems I can't produce a sample with similar set of cumulants using recipe above Commented Dec 14, 2019 at 19:40
• There is a difference between sample cumulants and the cumulants of a distribution. It is certainly possible to obtain a sample from a normal distribution with a variety of values for the sample cumulants. But only the 2nd cumulant from a normal distribution is non-zero. That begs the question: Do you need to sample from distributions with a specified set of cumulants or just have a set of numbers with matching sample cumulants without any consideration of a distribution?
– JimB
Commented Dec 14, 2019 at 22:35