code: def gofwrapper(f, loss_function='squared'):
      
  
      name = f.__name__[:-5]
      # Take a snapshot of the main namespace.
  
      # Find the functions needed to compute the gof points.
      expval_func = eval(name + '_expval')
      random_func = eval('r' + name)
  
      def wrapper(*args, **kwds):
          """
          This wraps a likelihood.
          """
  
          """Return gof points."""
  
          # Calculate loss
          loss = kwds.pop('gof', loss_functions[loss_function])
  
          # Expected value, given parameters
          expval = expval_func(*args[1:], **kwds)
          y = random_func(size=len(args[0]), *args[1:], **kwds)
          f.gof_points = GOFpoints(args[0], y, expval, loss)
  
          """Return likelihood."""
  
          return f(*args, **kwds)
  
      # Assign function attributes to wrapper.
      wrapper.__doc__ = f.__doc__
      wrapper.__name__ = f.__name__
      wrapper.name = name
  
      return wrapper
docs: Goodness-of-fit decorator function for likelihoods
      ==================================================
      Generates goodness-of-fit points for data likelihoods.
  
      Wrap function f(*args, **kwds) where f is a likelihood.
  
      Assume args = (x, parameter1, parameter2, ...)
      Before passing the arguments to the function, the wrapper makes sure that
      the parameters have the same shape as x.