Error with custom distribution (discrete uniform) in metamodel calculate

Hi UQWorld!

I’m starting in UQLab and I’m trying to create my PC-Kriging Metamodel, but there is a problem that I can’t solve.

One of my input variables fits a discrete uniform distribution. I have created the discrete uniform distribution and when I get samples with uq_getSample, it works perfectly.
However, when I try to create my Metamodel, I get the following error:
The integration for the recurrence coefficients returned NaN for degree 2!
I have entered all the parameters of the input.marginal (name, type and parameters) and the samples are correct. I don’t understand what is the problem, because if I enter the Uniform distribution of UQLab, it works perfectly, but with my discrete uniform distribution, I get this error.

If someone had the same problem or can tell me how enter discrete variables in the creation of the metamodel, I hope you can help me to solve it.

1 Like

Dear Jorge

Thanks for your question. So far (as of V.1.3) UQLab does not support discrete distributions.
What I mean is that you can indeed define your own custom distribution, which may be used for sampling, but the other modules (e.g. PCE) will not “support” it, i.e. will not work properly. In the case of PCE, the reason is that the way arbitrary polynomials are constructed for custom continuous distributions will not work for discrete ones.

To solve your problem anyway, I suggest you use a continuous uniform distribution, and use a rounding to get the discrete values that are needed as inputs for your MODEL. This can be done after uq_getSample(N), e.g. using the floor or ceil functions.

Best regards


Hi @Jorlo,

Were you able to solve your problem with the solution proposed above?

If you still run into problem, let us know :slight_smile:!

Hi, I try to jump back in the topic :slight_smile:
Is the discrete distribution not yet implemented in the last version of UQlab?
How can I work with discrete variables in the PCE module?
Gian Marco