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

Parameters class using 'distribution=' parameter results in an error #58

Open
goghino opened this issue Aug 26, 2021 · 0 comments
Open

Comments

@goghino
Copy link

goghino commented Aug 26, 2021

Hi, I am trying to run the coffee cup example with dependant variables. I am passing the dependant distribution to the Uncertainpy as Parameters(distribution=joint_mvNorm), which later fails with an error. I am using the following code:

#!/usr/bin/env python
# coding: utf-8

import uncertainpy as un
import chaospy as cp
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt

def coffee_cup_dependent(T_env, alpha):
    # Initial temperature and time
    time = np.linspace(0, 200, 150)            # Minutes
    T_0 = 95                                   # Celsius

    # The equation describing the model
    def f(T, time, alpha, T_env):
        return -alpha*(T - T_env)

    # Solving the equation by integration.
    temperature = odeint(f, T_0, time, args=(alpha, T_env))[:, 0]

    # Return time and model results
    return time, temperature


model = un.Model(run=coffee_cup_dependent, labels=["Time (min)", "Temperature (C)"])


#alpha, T_env
mean_param = [0.2, 20]
cov_param = [[0.0005, 0.01], [0.01, 1.5]]
joint_mvNorm = cp.MvNormal(mean_param, cov_param)

parameters = un.Parameters(distribution=joint_mvNorm)


# Set up the uncertainty quantification
UQ = un.UncertaintyQuantification(model=model, parameters=parameters)


# Perform the uncertainty quantification using polynomial chaos with point collocation (by default)
data = UQ.quantify(method="pc",
                 pc_method="collocation",
                 rosenblatt=True,
                 uncertain_parameters=None,
                 polynomial_order=4,
                 nr_collocation_nodes=None,
                 quadrature_order=None,
                 nr_pc_mc_samples=10**4,
                 nr_mc_samples=10**4,
                 allow_incomplete=False,
                 seed=None,
                 single=False,
                 plot="condensed_first",
                 figure_folder="figures",
                 figureformat=".png",
                 save=True,
                 data_folder="data",
                 filename=None,)

Running the script above produces an error:

Traceback (most recent call last):
  File "coffee_cup_dep_ucpy.py", line 92, in <module>
    data = UQ.quantify(method="pc",
  File "/Users/Juraj/anaconda3/envs/uncertainpy/lib/python3.9/site-packages/uncertainpy/uncertainty.py", line 415, in quantify
    data = self.polynomial_chaos(uncertain_parameters=uncertain_parameters,
  File "/Users/Juraj/anaconda3/envs/uncertainpy/lib/python3.9/site-packages/uncertainpy/uncertainty.py", line 702, in polynomial_chaos
    self.data = self.uncertainty_calculations.polynomial_chaos(
  File "/Users/Juraj/anaconda3/envs/uncertainpy/lib/python3.9/site-packages/uncertainpy/core/uncertainty_calculations.py", line 1345, in polynomial_chaos
    self.create_PCE_collocation_rosenblatt(uncertain_parameters=uncertain_parameters,
  File "/Users/Juraj/anaconda3/envs/uncertainpy/lib/python3.9/site-packages/uncertainpy/core/uncertainty_calculations.py", line 925, in create_PCE_collocation_rosenblatt
    dist_R = cp.J(*dist_R)
  File "/Users/Juraj/anaconda3/envs/uncertainpy/lib/python3.9/site-packages/chaospy/distributions/operators/joint.py", line 54, in __init__
    super(J, self).__init__(
  File "/Users/Juraj/anaconda3/envs/uncertainpy/lib/python3.9/site-packages/chaospy/distributions/baseclass/distribution.py", line 73, in __init__
    assert min(rotation) == 0
ValueError: min() arg is an empty sequence

My environment:

conda create --name uncertainpy
conda activate uncertainpy
conda install pip
pip install uncertainpy
conda list -n uncertainpy
# packages in environment:
#
# Name                    Version                   Build  Channel
chaospy                   4.3.3                    pypi_0    pypi
numpoly                   1.2.3                    pypi_0    pypi
uncertainpy               1.2.3                    pypi_0    pypi
...
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

1 participant