docstr: OUQ model for a statistical quantity
  
  Input:
      model: function of the form y = model(x, axis=None)
      bounds: mystic.bounds.MeasureBounds instance
  
  Additional Input:
      samples: int, number of samples (used for non-deterministic models)
      penalty: function of the form y' = penalty(x)
      constraint: function of the form x' = constraint(x)
      xvalid: function returning True if x == x', given constraint
      cvalid: function similar to xvalid, but with product_measure input
      map: map instance, to evaluate model on the product_measure in parallel
  
  NOTE: when y is multivalued models must be a UQModel with ny != None
      
docstr_tok: ["OUQ","model","for","a","statistical","quantity","Input",":","model",":","function","of","the","form","y","=","model","(","x",",","axis=None",")","bounds",":","mystic.bounds.MeasureBounds","instance","Additional","Input",":","samples",":","int",",","number","of","samples","(","used","for","non-deterministic","models",")","penalty",":","function","of","the","form","y","'","=","penalty","(","x",")","constraint",":","function","of","the","form","x","'","=","constraint","(","x",")","xvalid",":","function","returning","True","if","x","==","x","'",",","given","constraint","cvalid",":","function","similar","to","xvalid",",","but","with","product_measure","input","map",":","map","instance",",","to","evaluate","model","on","the","product_measure","in","parallel","NOTE",":","when","y","is","multivalued","models","must","be","a","UQModel","with","ny","!","=","None"]
code: def __init__(self, model, bounds, **kwds):
      """OUQ model for a statistical quantity
  
      Input:
          model: function of the form y = model(x, axis=None)
          bounds: mystic.bounds.MeasureBounds instance
  
      Additional Input:
          samples: int, number of samples (used for non-deterministic models)
          penalty: function of the form y' = penalty(x)
          constraint: function of the form x' = constraint(x)
          xvalid: function returning True if x == x', given constraint
          cvalid: function similar to xvalid, but with product_measure input
          map: map instance, to evaluate model on the product_measure in parallel
  
      NOTE: when y is multivalued models must be a UQModel with ny != None
      """
      self.npts = bounds.n  # (2,1,1)
      self.lb = bounds.lower
      self.ub = bounds.upper
      # NOTE: for *_bound(axis=None) to work, requires ny != None
      # if not isinstance(model, WrapModel.mro()[-2]):
      #    model = WrapModel(model=model)
      self.model = model
      self.axes = getattr(model, "ny", None)  # FIXME: in kwds?, ny
      rnd = getattr(model, "rnd", True)  # FIXME: ?, rnd
      self.samples = kwds.get("samples", None) if rnd else None
      self.map = None if self.samples is None else kwds.get("map", None)
      self.penalty = kwds.get("penalty", lambda rv: 0.0)
      self.constraint = kwds.get("constraint", lambda rv: rv)
      self.xvalid = kwds.get("xvalid", lambda rv: True)
      self.cvalid = kwds.get("cvalid", lambda c: True)
      self._invalid = float("inf")  # XXX: need to save state?
      self.kwds = {}  # XXX: good idea???
      self._upper = {}  # saved solver instances for upper bounds
      self._lower = {}  # saved solver instances for lower bounds
      self._expect = {}  # saved solver instances for expected value
      self._ave = {}  # saved expected value from sampling
      self._var = {}  # saved expected variance from sampling
      self._err = {}  # saved misfit to sampled expected value
      self._cost = (
          {}
      )  # saved cache of the most recent cost (for penalty)
      self._pts = (
          {}
      )  # saved sampled {in:out} objective #XXX: out only? ''?
      return
  
imports: import mystic.cache
  from mystic.cache import cached
  from mystic.cache.archive import dict_archive, file_archive, read
  from mystic.math import almostEqual
  from mystic.math.discrete import product_measure
  from mystic.math.samples import random_samples
  from mystic.solvers import DifferentialEvolutionSolver2
  from mystic.monitors import Monitor
  from ouq_models import WrapModel
label_desc: Use image node_id 1 to create a new BaseOUQ object from inherited base classes: object with example: obj = BaseOUQ(model, bounds)