Calculate cumulative frequencies along a certain axis.

        Returns
        -------
        new_hist: Histogram of the same type & size
964009
def accumulate(self, axis: AxisIdentifier) -> HistogramBase:
        
        # TODO: Merge with Histogram1D.cumulative_frequencies
        # TODO: Deal with errors and totals etc.
        # TODO: inplace
        new_one = self.copy()
        axis_id = self._get_axis(axis)
        new_one._frequencies = np.cumsum(new_one.frequencies, axis_id[0])
        return new_one
138178
def hist2d(self, da, **kwargs):
        """"""
        if self.value is None or self.value == 'counts':
            normed = False
        else:
            normed = True
        y = da.values
        x = da.coords[da.dims[0]].values
        counts, xedges, yedges = np.histogram2d(
            x, y, normed=normed, **kwargs)
        if self.value == 'counts':
            counts = counts / counts.sum().astype(float)
        return counts, xedges, yedges
504476
function TimeseriesHistogram( canvas, width, height, left, top ) {
		var graph, data, histogram, edges, axes, annotations, title, text, means;

		// [1] Instantiate a new graph generator and configure:
		graph = xfig.graph( canvas )
			.width( width )
			.height( height )
			.position({
				'left': left,
				'top': top
			})
			.xMin( 0 )
			.xMax( 1 );

		// Create the graph:
		graph.create( 'timeseries-histogram' );

		// Get data:
		d3.json( 'data/timeseries-histogram.data.json', function ( error, json ) {

			// [2] Instantiate a new data generator and configure:
			data = xfig.data( json )
				.accessors( 'x', function ( d ) {
					return d[ 0 ];
				})
				.accessors( 'y', function ( d ) {
					return d[ 1 ];
				});

			// Create edges to define our histogram bins:
			edges = xfig.vector.linspace( -0.025, 1.025, 0.05 );
			
			// Format the data and extract the data to histogram:
			data.format( [ 'x', 'y' ] )
				.extract( function ( d ) {
					return d[ 1 ];
				});

			// Calculate each dataset's mean value and sort the datasets based on their means:
			means = data.mean( function ( d ) {
				return d;
			});
			means = means.map( function ( d, i ) {
				return [ d, i ];
			});
			means.sort( function ( a, b ) {
				return a[0] < b[0] ? -1 : ( a[0] > b[0] ? 1 : 0 );
			});
			means = means.map( function ( d ) {
				return d[ 1 ];
			});

			// Calculate the histogram:
			data.reorder( means )
				.histc( function ( d ) { return d; }, edges );

			// Bind the data instance to the graph:
			graph.data( data )
				.yMin( 0 )
				.yMax( data.size()[0] )
				.zMin( 0 )
				.zMax( data.max( function ( d ) {
					return d[ 1 ];
				}))
				.zRange( ['#ffffff', '#000000'] );

			// [3] Instantiate a new histogram generator and configure:
			histogram = xfig.timeserieshistogram( graph );

			// Create the histogram:
			histogram.create();

			// [4] Instantiate a new axes generator and configure:
			axes = xfig.axes( graph )
				.xLabel( 'percent' )
				.yLabel( 'index' );

			// Create the axes:
			axes.create();

			// [5] Instantiate a new annotations generator and configure:
			annotations = xfig.annotations( graph );

			// Create the annotations element:
			annotations.create();

			// [5.1] Instantiate a new title instance and configure:
			title = annotations.title()
				.top( -30 )
				.left( 0 );

			// Add a (sub)title:
			title.create( 'Subtitle' );

		});

	}
341844
def frequency(self, data_frame):
        
        freq = sum(data_frame.action_type == 1) / data_frame.td[-1]
        duration = math.ceil(data_frame.td[-1])

        return freq, duration
753720
def _iter_frequencies(self):
        
        # work out how many frequencies we need
        minf, maxf = self.frange
        fcum_mismatch = log(maxf / minf) * (2 + self.q**2)**(1/2.) / 2.
        nfreq = int(max(1, ceil(fcum_mismatch / self.deltam)))
        fstep = fcum_mismatch / nfreq
        fstepmin = 1 / self.duration
        # for each frequency, yield a QTile
        for i in xrange(nfreq):
            yield (minf *
                   exp(2 / (2 + self.q**2)**(1/2.) * (i + .5) * fstep) //
                   fstepmin * fstepmin)
921861
def from_histogram(cls, histogram, bin_edges, axis_names=None):
        
        bin_edges = np.array(bin_edges)
        self = cls(bins=bin_edges, axis_names=axis_names)
        self.histogram = histogram
        return self
472270
def cumsum(x, axis=0, exclusive=False):
  
  if not is_xla_compiled():
    return tf.cumsum(x, axis=axis, exclusive=exclusive)
  x_shape = shape_list(x)
  rank = len(x_shape)
  length = x_shape[axis]
  my_range = tf.range(length)
  comparator = tf.less if exclusive else tf.less_equal
  mask = tf.cast(
      comparator(tf.expand_dims(my_range, 1), tf.expand_dims(my_range, 0)),
      x.dtype)
  ret = tf.tensordot(x, mask, axes=[[axis], [0]])
  if axis != rank - 1:
    ret = tf.transpose(
        ret,
        list(range(axis)) + [rank - 1] + list(range(axis, rank - 1)))
  return ret
1241014
def normalize_bins(self, inplace: bool = False) -> "HistogramCollection":
        
        col = self if inplace else self.copy()
        sums = self.sum().frequencies
        for h in col.histograms:
            h.set_dtype(float)
            h._frequencies /= sums
            h._errors2 /= sums ** 2  # TODO: Does this make sense?
        return col
1179720
def from_xarray(cls, arr: "xarray.Dataset") -> "Histogram1D":
        
        kwargs = {'frequencies': arr["frequencies"],
                  'binning': arr["bins"],
                  'errors2': arr["errors2"],
                  'overflow': arr.attrs["overflow"],
                  'underflow': arr.attrs["underflow"],
                  'keep_missed': arr.attrs["keep_missed"]}
        # TODO: Add stats
        return cls(**kwargs)
110481
def copy(self, include_frequencies: bool = True) -> "HistogramBase":
        
        if include_frequencies:
            frequencies = np.copy(self.frequencies)
            missed = self._missed.copy()
            errors2 = np.copy(self.errors2)
            stats = self._stats or None
        else:
            frequencies = np.zeros_like(self._frequencies)
            errors2 = np.zeros_like(self._errors2)
            missed = np.zeros_like(self._missed)
            stats = None
        a_copy = self.__class__.__new__(self.__class__)
        a_copy._binnings = [binning.copy() for binning in self._binnings]
        a_copy._dtype = self.dtype
        a_copy._frequencies = frequencies
        a_copy._errors2 = errors2
        a_copy._meta_data = self._meta_data.copy()
        a_copy.keep_missed = self.keep_missed
        a_copy._missed = missed
        a_copy._stats = stats
        return a_copy
126097
def frequency_axis(self):
        
        return numpy.linspace(-self.sw / 2, self.sw / 2, self.np, endpoint=False)
220299
def fill_n(self, values, weights=None, dropna: bool = True):
        
        # TODO: Unify with HistogramBase
        values = np.asarray(values)
        if dropna:
            values = values[~np.isnan(values)]
        if self._binning.is_adaptive():
            map = self._binning.force_bin_existence(values)
            self._reshape_data(self._binning.bin_count, map)
        if weights:
            weights = np.asarray(weights)
            self._coerce_dtype(weights.dtype)
        (frequencies, errors2, underflow, overflow, stats) = \
            calculate_frequencies(values, self._binning, dtype=self.dtype,
                                  weights=weights, validate_bins=False)
        self._frequencies += frequencies
        self._errors2 += errors2
        # TODO: check that adaptive does not produce under-/over-flows?
        if self.keep_missed:
            self.underflow += underflow
            self.overflow += overflow
        if self._stats:
            for key in self._stats:
                self._stats[key] += stats.get(key, 0.0)
535677
def histogram(title, title_x, title_y,
              x, bins_x):
    
    plt.figure()
    plt.hist(x, bins_x)
    plt.xlabel(title_x)
    plt.ylabel(title_y)
    plt.title(title)
834676
def _compute_counts_from_intensity(intensity, bexpcube):
        
        data = intensity.data * np.sqrt(bexpcube.data[1:] * bexpcube.data[0:-1])
        return HpxMap(data, intensity.hpx)
378299
def score_hist(df, columns=None, groupby=None, threshold=0.7, stacked=True,
               bins=20, percent=True, alpha=0.33, show=True, block=False, save=False):
    
    df = df if columns is None else df[([] if groupby is None else [groupby]) + list(columns)].copy()
    if groupby is not None or threshold is not None:
        df = groups_from_scores(df, groupby=groupby, threshold=threshold)
    percent = 100. if percent else 1.
    if isinstance(df, pd.core.groupby.DataFrameGroupBy):
        df = df_from_groups(df, columns=columns) * percent
    columns = df.columns if columns is None else columns
    if bins is None:
        bins = 20
    if isinstance(bins, int):
        bins = np.linspace(np.min(df.min()), np.max(df.max()), bins)
    log.debug('bins: {}'.format(bins))
    figs = []

    df.plot(kind='hist', alpha=alpha, stacked=stacked, bins=bins)
    # for col in df.columns:
    #     series = df[col] * percent
    #     log.debug('{}'.format(series))
    #     figs.append(plt.hist(series, bins=bins, alpha=alpha,
    #                 weights=percent * np.ones_like(series) / len(series.dropna()),
    #                 label=stringify(col)))
    plt.legend()
    plt.xlabel('Score (%)')
    plt.ylabel('Percent')
    plt.title('{} Scores for {}'.format(np.sum(df.count()), columns))
    plt.draw()
    if save or not show:
        fig = plt.gcf()
        today = datetime.datetime.today()
        fig.savefig(os.path.join(IMAGES_PATH, 'score_hist_{:04d}-{:02d}-{:02d}_{:02d}{:02d}.jpg'.format(*today.timetuple())))
    if show:
        plt.show(block=block)
    return figs
37776
def alpha_hist(freqs, scale, fg, bg)
      histogram = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do
        self.background_color = bg
        self.border_color = fg
      end

      gc = Draw.new
      gc.affine(1, 0, 0, -scale, 0, HISTOGRAM_ROWS)
      gc.fill('white')

      HISTOGRAM_COLS.times do |x|
        gc.point(x, freqs[x])
      end

      gc.draw(histogram)
      histogram['Label'] = 'Alpha'

      histogram
    end
1151432
def spectrum(self):
        
        return numpy.fft.fftshift(numpy.fft.fft(self, axis=-1), axes=-1)