How to use the mc3.stats.chisq function in mc3

To help you get started, we’ve selected a few mc3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pcubillos / mc3 / tests / test_stats.py View on Github external
def test_chisq_no_priors():
    data   = np.array([1.1, 1.2, 0.9, 1.0])
    model  = np.array([1.0, 1.0, 1.0, 1.0])
    uncert = np.array([0.1, 0.1, 0.1, 0.1])
    chisq  = ms.chisq(model, data, uncert)
    assert chisq == 6.0
github pcubillos / mc3 / tests / test_stats.py View on Github external
def test_chisq():
    data   = np.array([1.1, 1.2, 0.9, 1.0])
    model  = np.array([1.0, 1.0, 1.0, 1.0])
    uncert = np.array([0.1, 0.1, 0.1, 0.1])
    params = np.array([2.5, 5.5])
    priors = np.array([2.0, 5.0])
    plow   = np.array([0.0, 1.0])
    pup    = np.array([0.0, 1.0])
    chisq = ms.chisq(model, data, uncert, params, priors, plow, pup)
    assert chisq == 6.25
github pcubillos / mc3 / mc3 / chain.py View on Github external
"""
      if self.wlike:
          model = self.func(params[0:-3], *self.args)
      else:
          model = self.func(params, *self.args)

      # Reject proposed iteration if any model value is infinite:
      if np.any(model == np.inf):
          chisq = np.inf
      else:
          # Calculate chisq:
          if self.wlike:
              chisq = ms.dwt_chisq(model, self.data, params,
                  self.prior, self.priorlow, self.priorup)
          else:
              chisq = ms.chisq(model, self.data, self.uncert,
                  params, self.prior, self.priorlow, self.priorup)

      if ret == "both":
          return [model, chisq]
      elif ret == "chisq":
          return chisq
      else:  # ret == "model"
          return model