def plot(Y, axis=-1, scale=2, center=False, **kwargs): """ Plot a variable or an array as 1-D function with errorbars """ if misc.is_numeric(Y): return _timeseries_mean_and_error(Y, None, axis=axis, center=center, **kwargs) if isinstance(Y, Node): # Try Bernoulli plotting try: Y = Y._ensure_moments(Y, BernoulliMoments) except BernoulliMoments.NoConverterError: pass else: return plot_bernoulli(Y, axis=axis, scale=scale, center=center, **kwargs) # Try Gaussian plotting try: Y = Y._ensure_moments(Y, GaussianMoments, ndim=0) except GaussianMoments.NoConverterError: pass else: return plot_gaussian(Y, axis=axis, scale=scale, center=center, **kwargs) (mu, var) = Y.get_mean_and_variance() std = np.sqrt(var) return _timeseries_mean_and_error(mu, std, axis=axis, scale=scale, center=center, **kwargs)
def __init__(self, covfunc, *args, **kwargs): self.covfunc = covfunc params = list(args) for i in range(len(args)): # Check constant parameters if utils.is_numeric(args[i]): params[i] = ef.NodeConstant([np.asanyarray(args[i])], dims=[np.shape(args[i])]) # TODO: Parameters could be constant functions? :) ef.Node.__init__(self, *params, dims=[(np.inf, np.inf)], **kwargs)
def __init__(self, alpha, **kwargs): # Check for constant if misc.is_numeric(alpha): alpha = Constant(Gamma)(alpha) # FIXME: Put import here to avoid circular dependency import from .wishart import WishartMoments self._moments = WishartMoments(()) dims = ((), ()) # Construct the node super().__init__(alpha, dims=self._moments.dims, **kwargs)
def __init__(self, alpha, **kwargs): # Check for constant if misc.is_numeric(alpha): alpha = Constant(Gamma)(alpha) if len(alpha.plates) == 0: raise Exception("Gamma variable needs to have plates in " "order to be used as a diagonal Wishart.") D = alpha.plates[-1] # FIXME: Put import here to avoid circular dependency import from .wishart import WishartMoments self._moments = WishartMoments((D, )) dims = ((D, D), ()) # Construct the node super().__init__(alpha, dims=self._moments.dims, **kwargs)
def __init__(self, alpha, **kwargs): # Check for constant if misc.is_numeric(alpha): alpha = Constant(Gamma)(alpha) if len(alpha.plates) == 0: raise Exception("Gamma variable needs to have plates in " "order to be used as a diagonal Wishart.") D = alpha.plates[-1] # FIXME: Put import here to avoid circular dependency import from .wishart import WishartMoments self._moments = WishartMoments((D,)) dims = ( (D,D), () ) # Construct the node super().__init__(alpha, dims=self._moments.dims, **kwargs)
def __init__(self, alpha, **kwargs): # Check for constant if misc.is_numeric(alpha): alpha = Constant(Gamma)(alpha) # Remove the last plate... #plates = alpha.plates[:-1] # ... and use it as the dimensionality of the Wishart # distribution if len(alpha.plates) == 0: raise Exception("Gamma variable needs to have plates in " "order to be used as a diagonal Wishart.") D = alpha.plates[-1] dims = ( (D,D), () ) # Construct the node super().__init__(alpha, #plates=plates, dims=dims, **kwargs)
def __init__(self, alpha, **kwargs): # Check for constant if misc.is_numeric(alpha): alpha = Constant(Gamma)(alpha) # Remove the last plate... #plates = alpha.plates[:-1] # ... and use it as the dimensionality of the Wishart # distribution if len(alpha.plates) == 0: raise Exception("Gamma variable needs to have plates in " "order to be used as a diagonal Wishart.") D = alpha.plates[-1] dims = ((D, D), ()) # Construct the node super().__init__( alpha, #plates=plates, dims=dims, **kwargs)