python-igraph manual

For using igraph from Python

   Home       Trees       Indices       Help   
Package igraph :: Module statistics :: Class Histogram
[hide private]

Class Histogram

source code

object --+
         |
        Histogram

Generic histogram class for real numbers

Example:

>>> h = Histogram(5)     # Initializing, bin width = 5
>>> h << [2,3,2,7,8,5,5,0,7,9]     # Adding more items
>>> print h
N = 10, mean +- sd: 4.8000 +- 2.9740
[ 0,  5): **** (4)
[ 5, 10): ****** (6)
Instance Methods [hide private]
 
__init__(self, bin_width=1, data=None)
Initializes the histogram with the given data set.
source code
 
_get_bin(self, num, create=False)
Returns the bin index corresponding to the given number.
source code
 
add(self, num, repeat=1)
Adds a single number to the histogram.
source code
 
add_many(self, data)
Adds a single number or the elements of an iterable to the histogram.
source code
 
__lshift__(self, data)
Adds a single number or the elements of an iterable to the histogram.
source code
 
clear(self)
Clears the collected data
source code
 
bins(self)
Generator returning the bins of the histogram in increasing order
source code
 
__plot__(self, context, bbox, _, **kwds)
Plotting support
source code
 
to_string(self, max_width=78, show_bars=True, show_counts=True)
Returns the string representation of the histogram.
source code
 
__str__(self)
str(x)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  n
Returns the number of elements in the histogram
  mean
Returns the mean of the elements in the histogram
  sd
Returns the standard deviation of the elements in the histogram
  var
Returns the variance of the elements in the histogram

Inherited from object: __class__

Method Details [hide private]

__init__(self, bin_width=1, data=None)
(Constructor)

source code 

Initializes the histogram with the given data set.

Parameters:
  • bin_width - the bin width of the histogram.
  • data - the data set to be used. Must contain real numbers.
Overrides: object.__init__

_get_bin(self, num, create=False)

source code 

Returns the bin index corresponding to the given number.

Parameters:
  • num - the number for which the bin is being sought
  • create - whether to create a new bin if no bin exists yet.
Returns:
the index of the bin or None if no bin exists yet and {create} is False.

add(self, num, repeat=1)

source code 

Adds a single number to the histogram.

Parameters:
  • num - the number to be added
  • repeat - number of repeated additions

add_many(self, data)

source code 

Adds a single number or the elements of an iterable to the histogram.

Parameters:
  • data - the data to be added

__lshift__(self, data)

source code 

Adds a single number or the elements of an iterable to the histogram.

Parameters:
  • data - the data to be added

bins(self)

source code 

Generator returning the bins of the histogram in increasing order

Returns:
a tuple with the following elements: left bound, right bound, number of elements in the bin

to_string(self, max_width=78, show_bars=True, show_counts=True)

source code 

Returns the string representation of the histogram.

Parameters:
  • max_width - the maximal width of each line of the string This value may not be obeyed if it is too small.
  • show_bars - specify whether the histogram bars should be shown
  • show_counts - specify whether the histogram counts should be shown. If both show_bars and show_counts are False, only a general descriptive statistics (number of elements, mean and standard deviation) is shown.

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Property Details [hide private]

n

Returns the number of elements in the histogram

Get Method:
unreachable.n(self) - Returns the number of elements in the histogram

mean

Returns the mean of the elements in the histogram

Get Method:
unreachable.mean(self) - Returns the mean of the elements in the histogram

sd

Returns the standard deviation of the elements in the histogram

Get Method:
unreachable.sd(self) - Returns the standard deviation of the elements in the histogram

var

Returns the variance of the elements in the histogram

Get Method:
unreachable.var(self) - Returns the variance of the elements in the histogram

   Home       Trees       Indices       Help