public class IntegerDistribution extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
private ConcurrentMap<Integer,Integer> |
bins |
private static RNG |
GENERATOR |
Constructor and Description |
---|
IntegerDistribution()
Create an empty distribution.
|
IntegerDistribution(int nbins)
Create the distribution with a specified number of bins.
|
Modifier and Type | Method and Description |
---|---|
void |
add(IntegerDistribution hist)
Adds the content of the argument to the current object.
|
void |
clear()
Clear all the data from the distribution, after this method the distribution has no denominator or frequency.
|
IntegerDistribution |
copy()
Creates a copy of this histogram and returns it.
|
Collection<Integer> |
getBinContents()
Get a collection of the values held in the histogram.
|
Collection<Integer> |
getBins()
Get the bins in the histogram.
|
Integer |
getData(Integer bin)
Deprecated.
use getFrequency() instead
|
Integer |
getFrequency(Integer bin)
Get the size of the histogram at the given bin.
|
int |
getNumBins()
Get the number of bins.
|
Integer |
getRandomBin()
Select a random bin from the cumulative distribution of the histograms contents.
|
Integer |
getRandomBinFrequency()
Select a random bin from the cumulative distribution of the frequencies and return the frequency.
|
Integer |
getSumCounts()
Get the sum of the counts in the histogram.
|
private void |
init(int nbins)
Add a number of entries (keys) to the histogram (with zero value).
|
IntegerDistribution |
normaliseBins(int constant)
Normalise the frequency distribution.
|
void |
reset()
Resets the value in each bin.
|
void |
reset(int val)
Resets the value in each bin.
|
IntegerDistribution |
scaleBins(double factor)
Scale the values in the histogram by a given factor.
|
void |
setData(Integer bin)
Deprecated.
use getFrequency() instead
|
void |
setData(Integer bin,
Integer data)
Deprecated.
use setFrequency() instead
|
void |
setFrequency(Integer bin)
Increment the size of a bin.
|
void |
setFrequency(Integer bin,
Integer data)
Set the value of a bin.
|
int |
size()
Get the size (the number of bins) in the histogram.
|
int[] |
toArray()
Get an array of the bin values.
|
String |
toCsv()
Get a string representation of the histogram in a csv format.
|
long[] |
toLongArray()
Get an array of the bin values.
|
String |
toString()
Get a string representation of the histogram.
|
private ConcurrentMap<Integer,Integer> bins
private static final RNG GENERATOR
public IntegerDistribution()
public IntegerDistribution(int nbins)
nbins
- the number of binsprivate void init(int nbins)
nbins
- the number of bins to add.public void clear()
public final void reset(int val)
val
- the reset value.public final void reset()
public final void add(IntegerDistribution hist)
hist
- the histogram data to add.public final int getNumBins()
public final void setFrequency(Integer bin)
bin
- the bin to increment.public final void setFrequency(Integer bin, Integer data)
bin
- the bin.data
- the data.public final Integer getFrequency(Integer bin)
bin
- the bin.public final void setData(Integer bin)
bin
- the bin to increment.public final void setData(Integer bin, Integer data)
bin
- the bin.data
- the data.public final Integer getData(Integer bin)
bin
- the bin.public final Integer getRandomBin()
public final Integer getRandomBinFrequency()
public final IntegerDistribution copy()
public final Integer getSumCounts()
public final Collection<Integer> getBins()
public final Collection<Integer> getBinContents()
public final int size()
public final int[] toArray()
public final long[] toLongArray()
public final IntegerDistribution scaleBins(double factor)
factor
- the value by which every value in the hiistogram will be multiplied.public final IntegerDistribution normaliseBins(int constant)
constant
- the normalising constantpublic final String toString()
public final String toCsv()
Copyright © 2015 University of Glasgow. All rights reserved.