class_docstr: A class representing empirical distribution.
  
  The target can be vector/tensor-valued, i.e., `event_shape` can be larger
  than or equal to 1. However, note that each dimension is assumed to be
  independent when computing variance and CRPS loss.
  
  Also, for computing CDF and quantiles, it is assumede that samples are
  distinct along the samples dimension, which should almost always be the
  case if samples are drawn from continuous distributions.
  
  Parameters
  ----------
  samples
      Tensor containing samples, of shape
      `(num_samples, *batch_shape, *event_shape)`.
  event_dim
      Number of event dimensions, i.e., length of the `event_shape` tuple.
      This is `0` for distributions over scalars, `1` over vectors,
      `2` over matrices, and so on.
class_docstr_tok: ["A","class","representing","empirical","distribution",".","The","target","can","be","vector\/tensor-valued",",","i.e.",",","`","event_shape","`","can","be","larger","than","or","equal","to","1",".","However",",","note","that","each","dimension","is","assumed","to","be","independent","when","computing","variance","and","CRPS","loss",".","Also",",","for","computing","CDF","and","quantiles",",","it","is","assumede","that","samples","are","distinct","along","the","samples","dimension",",","which","should","almost","always","be","the","case","if","samples","are","drawn","from","continuous","distributions",".","Parameters","--","--","--","--","--","samples","Tensor","containing","samples",",","of","shape","`","(","num_samples",",","*","batch_shape",",","*","event_shape",")","`",".","event_dim","Number","of","event","dimensions",",","i.e.",",","length","of","the","`","event_shape","`","tuple",".","This","is","`","0","`","for","distributions","over","scalars",",","`","1","`","over","vectors",",","`","2","`","over","matrices",",","and","so","on","."]
docstr: Compute the *continuous rank probability score* (CRPS) of `obs`
  according to the empirical distribution.
  
  The last dimension of `obs` specifies the "event dimension" of the
  target (= 1 for the univariate case). For multivariate target, CRSP
  scores are computed for each dimension separately and then their sum
  is returned.
  
  Parameters
  ----------
  x
      Tensor of ground truth with shape `(*batch_shape, *event_shape)`
  
  Returns
  -------
  Tensor
      CRPS score of shape `(*batch_shape, 1)`.
docstr_tok: ["Compute","the","*","continuous","rank","probability","score","*","(","CRPS",")","of","`","obs","`","according","to","the","empirical","distribution",".","The","last","dimension","of","`","obs","`","specifies","the","``","event","dimension","''","of","the","target","(","=","1","for","the","univariate","case",")",".","For","multivariate","target",",","CRSP","scores","are","computed","for","each","dimension","separately","and","then","their","sum","is","returned",".","Parameters","--","--","--","--","--","x","Tensor","of","ground","truth","with","shape","`","(","*","batch_shape",",","*","event_shape",")","`","Returns","--","--","--","-","Tensor","CRPS","score","of","shape","`","(","*","batch_shape",",","1",")","`","."]
code: def crps_univariate(self, x: Tensor) -> Tensor:
      r"""Compute the *continuous rank probability score* (CRPS) of `obs`
      according to the empirical distribution.
  
      The last dimension of `obs` specifies the "event dimension" of the
      target (= 1 for the univariate case). For multivariate target, CRSP
      scores are computed for each dimension separately and then their sum
      is returned.
  
      Parameters
      ----------
      x
          Tensor of ground truth with shape `(*batch_shape, *event_shape)`
  
      Returns
      -------
      Tensor
          CRPS score of shape `(*batch_shape, 1)`.
      """
      F = self.F
      sorted_samples = self.sorted_samples
  
      # We compute quantile losses for all the possible quantile levels; i.e,
      # `num_quantiles` = `num_samples`.
      num_quantiles = sorted_samples.shape[0]
      levels_np = np.arange(
          1 / num_quantiles, 1 + 1 / num_quantiles, 1 / num_quantiles
      )
  
      # Quantiles are just sorted samples with a different shape
      # (for convenience): `(*batch_shape, *event_shape, num_quantiles)`
      axes_ordering = list(range(1, self.all_dim + 1))
      axes_ordering.append(0)
      quantiles = sorted_samples.transpose(axes_ordering)
  
      # Shape: `(*batch_shape, *event_shape, num_quantiles)`
      qlosses = self.quantile_losses(
          obs=x,
          quantiles=quantiles,
          levels=F.array(levels_np).broadcast_like(quantiles),
      )
  
      # CRPS for each target dimension. Shape: `
      # (*batch_shape, *event_shape)`
      crps = F.sum(qlosses, axis=-1)
  
      if self.event_dim > 0:
          # Total CRPS: sum over all but the axes corresponding to the batch
          # shape. Shape: `(*batch_shape)`
          crps = F.sum(
              crps,
              exclude=True,
              axis=list(range(0, len(self.batch_shape))),
          )
  
      return crps
  
imports: from typing import Optional, Tuple
  import numpy
  import mxnet
  from gluonts.core.component import validated
  from gluonts.mx import Tensor
  from .distribution import Distribution, getF
  from .distribution_output import DistributionOutput, ArgProj
label_desc: Use image node_id 12 for calling the EmpiricalDistribution obj's underlying member method code with example usage: obj.crps_univariate(x) and returns: crps