Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SC and PCE samplers do not support discrete distributions #169

Open
fjansson opened this issue Dec 2, 2019 · 1 comment
Open

SC and PCE samplers do not support discrete distributions #169

fjansson opened this issue Dec 2, 2019 · 1 comment
Assignees

Comments

@fjansson
Copy link

fjansson commented Dec 2, 2019

I'm trying to use a variable with a uniform integer distribution with the SC and PCE samplers. (Eventually, I want a distribution of {0, 1} for a random binary value).

params = {
    ...
    "l_sb": { # flag for microphysics scheme: false - KK00 Khairoutdinov and Kogan, 2000              
    "type": "integer",            #   true - SB   Seifert and Beheng, 2001, 2006, Default
    "min" : 0,  
    "max" : 20,   # converted to Fortran .true., .false. in prep.sh 
    "default" : 1
    }
}

vary = {
   ...
    "l_sb"    :  cp.DiscreteUniform(0, 10),
}

It seems the SC and PCE samplers do not respect the discrete distribution, but generate
real-valued sample points. Then, the generated parameters are checked and found to not obey the
constraints, integer values in this case.

Traceback:

Traceback (most recent call last):
  File "easyvvuq_dales_sc.py", line 171, in <module>
    my_campaign.draw_samples()
  File "/home/jansson/code/VECMA/uq_env/lib64/python3.7/site-packages/easyvvuq-0.3.1+187.ga809472-py3.7.egg/easyvvuq/campaign.py", line 529, in draw_samples
  File "/home/jansson/code/VECMA/uq_env/lib64/python3.7/site-packages/easyvvuq-0.3.1+187.ga809472-py3.7.egg/easyvvuq/campaign.py", line 464, in add_runs
  File "/home/jansson/code/VECMA/uq_env/lib64/python3.7/site-packages/easyvvuq-0.3.1+187.ga809472-py3.7.egg/easyvvuq/params_specification.py", line 109, in process_run

RuntimeError: Error when verifying the following new run:
{'Nc_0': 55635083.268962905, 'cf': 2.422540333075852, 'Prandtl': 0.2225403330758517, 'l_sb': 0.7809953780542012, 'cn': 0.76, 'Rigc': 0.25, 'z0': 0.00016}
Identified errors were:
{'l_sb': ['must be of integer type']}

Among the test cases, I only saw one example using a discrete distribution - test_worker.py, line 109.
It uses the RandomSampler.

  1. Is it possible to combine discrete integer distributions with SC and PCE sampling?
  2. If possible, there is an extra complication in that the number of allowed values may be less than the
    number of sampling points specified - e.g. 3rd order sampling and a binary variable. This might require allowing to have different orders for different variables.
jlakhlili added a commit that referenced this issue Dec 9, 2019
Update chaospy version to bing the fix issue #169 issue
@jlakhlili jlakhlili reopened this Jan 21, 2020
@jlakhlili jlakhlili pinned this issue Jan 21, 2020
@fjansson
Copy link
Author

Part of this issue was solved with a chaospy update. Here's a summary of the current state.

Solved: chaospy fixed non-integer points in quadrature rules, specifically with joint distributions, in version 3.2.1. Discussion in jonathf/chaospy#188

  • We should update the chaospy version in requirements.txt to at least 3.2.1.
    ( I have tested EasyVVUQ with chaospy 3.2.1. Chaospy 3.2.6 is available now - but EasyVVUQ doesn't work with it)

Still open: If a parameter is declared with "type": "integer", the validation fails on DiscreteUniform distributions because chaospy returns a float numpy array. Workaround: declare all variables with "type": "float".

Perhaps the validation should check the value and not the type. Potential source of confusion: when generating a chaospy quadrature of a join of only discrete distributions, the absicissas are returned as an integer array. But when generating a quadrature of a join of discrete and continuous distribution, the abscissas are returned as a float array. It doesn't seem easy or reasonable to change this.

@orbitfold orbitfold unpinned this issue May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants