rexfw.statistics.writers package

Module contents

StatisticsWriter classes which… well… write statistics to stdout / files / …

ATTENTION: some of these classes expect replica objects to be named replica1, replica2, …

class rexfw.statistics.writers.AbstractFileStatisticsWriter(filename, variables_to_write=[], quantities_to_write=[])[source]

Bases: rexfw.statistics.writers.AbstractStatisticsWriter

_write_quantity_class_header(class_name)[source]
_write_single_quantity_stats(elements)

Writes a single line to stdout / file, e.g., all sampler step sizes which would be stored in elements

Parameters:elements (list of LoggedQuantity) – quantities to write
write(step, elements)[source]

Writes quantities in elements for a given step

Parameters:
  • step (int) – sampling step
  • elements (list of LoggedQuantity) – list of quantities to write
class rexfw.statistics.writers.AbstractStatisticsWriter(separator, variables_to_write=[], quantities_to_write=[])[source]

Bases: object

_write_single_quantity_stats(elements)[source]

Writes a single line to stdout / file, e.g., all sampler step sizes which would be stored in elements

Parameters:elements (list of LoggedQuantity) – quantities to write
write(step, elements)[source]

Writes quantities in elements for a given step

Parameters:
  • step (int) – sampling step
  • elements (list of LoggedQuantity) – list of quantities to write
class rexfw.statistics.writers.ConsoleStatisticsWriter(variables_to_write=[], quantities_to_write=[])[source]

Bases: rexfw.statistics.writers.AbstractStatisticsWriter

_format(quantity)[source]

Formats the numeric value of a quantity for output

Parameters:quantity (LoggedQuantity) – a quantity whose numeric value will be written
Returns:a string representing a formatted numerical value
Return type:str
_sort_quantities(quantities)[source]

Sorts quantities for a single line by, e.g., replica name

Parameters:quantities (list of LoggedQuantity objects) – the logged quantitis which will be written out
Returns:the sorted quantities list
Return type:list
_write_all_but_header(quantities)[source]

Writes all sampling statistics in quantities, but not the line header

Parameters:quantities (list of LoggedQuantity) – a list of similar LoggedQuantity objects, e.g., all step sizes
_write_quantity_class_header(quantity)[source]

Writes a “header” (line beginning) for a given type of quantity, e.g., “myvariable p_acc”

Parameters:quantity (LoggedQuantity) – a quantity containing the information needed
Returns:a preface for a line with similar sampling statistics
Return type:str
_write_single_quantity_stats(elements)

Writes a single line to stdout / file, e.g., all sampler step sizes which would be stored in elements

Parameters:elements (list of LoggedQuantity) – quantities to write
_write_step_header(step)[source]

Writes a header for a given sampling step, e.g., ### step number ###

Parameters:step (int) – a sampling step
Returns:the header prefacing the ouptut for a given sampling step
Return type:str
write(step, elements)[source]

Writes quantities in elements for a given step

Parameters:
  • step (int) – sampling step
  • elements (list of LoggedQuantity) – list of quantities to write
class rexfw.statistics.writers.StandardConsoleMCMCStatisticsWriter(variables_to_write=[], quantities_to_write=[])[source]

Bases: rexfw.statistics.writers.ConsoleStatisticsWriter

Writes only acceptance rate and step sizes to stdout. Remember to set quantity names correctly, that is, to “acceptance rate” and “stepsize”

Parameters:
  • variables_to_write (list of str) – list of sampling variable names for which to write statistics
  • quantities_to_write (list of LoggedQuantity) – list of LoggedQuantity objects for which to write statistics
_format(quantity)[source]

Formats the numeric value of a quantity for output

Parameters:quantity (LoggedQuantity) – a quantity whose numeric value will be written
Returns:a string representing a formatted numerical value
Return type:str
_sort_quantities(quantities)[source]

Sorts quantities for a single line by, e.g., replica name

Parameters:quantities (list of LoggedQuantity objects) – the logged quantitis which will be written out
Returns:the sorted quantities list
Return type:list
_write_all_but_header(elements)[source]

Writes all sampling statistics in quantities, but not the line header

Parameters:quantities (list of LoggedQuantity) – a list of similar LoggedQuantity objects, e.g., all step sizes
_write_quantity_class_header(quantity)[source]

Writes a “header” (line beginning) for a given type of quantity, e.g., “myvariable p_acc”

Parameters:quantity (LoggedQuantity) – a quantity containing the information needed
Returns:a preface for a line with similar sampling statistics
Return type:str
_write_single_quantity_stats(elements)

Writes a single line to stdout / file, e.g., all sampler step sizes which would be stored in elements

Parameters:elements (list of LoggedQuantity) – quantities to write
_write_step_header(step)[source]

Writes a header for a given sampling step, e.g., ### step number ###

Parameters:step (int) – a sampling step
Returns:the header prefacing the ouptut for a given sampling step
Return type:str
write(step, elements)

Writes quantities in elements for a given step

Parameters:
  • step (int) – sampling step
  • elements (list of LoggedQuantity) – list of quantities to write
class rexfw.statistics.writers.StandardConsoleREStatisticsWriter[source]

Bases: rexfw.statistics.writers.ConsoleStatisticsWriter

_format(quantity)[source]

Formats the numeric value of a quantity for output

Parameters:quantity (LoggedQuantity) – a quantity whose numeric value will be written
Returns:a string representing a formatted numerical value
Return type:str
_sort_quantities(quantities)[source]

Sorts quantities for a single line by, e.g., replica name

Parameters:quantities (list of LoggedQuantity objects) – the logged quantitis which will be written out
Returns:the sorted quantities list
Return type:list
_write_all_but_header(quantities)

Writes all sampling statistics in quantities, but not the line header

Parameters:quantities (list of LoggedQuantity) – a list of similar LoggedQuantity objects, e.g., all step sizes
_write_quantity_class_header(class_name)[source]

Writes a “header” (line beginning) for a given type of quantity, e.g., “myvariable p_acc”

Parameters:quantity (LoggedQuantity) – a quantity containing the information needed
Returns:a preface for a line with similar sampling statistics
Return type:str
_write_single_quantity_stats(elements)

Writes a single line to stdout / file, e.g., all sampler step sizes which would be stored in elements

Parameters:elements (list of LoggedQuantity) – quantities to write
_write_step_header(step)[source]

Writes a header for a given sampling step, e.g., ### step number ###

Parameters:step (int) – a sampling step
Returns:the header prefacing the ouptut for a given sampling step
Return type:str
write(step, elements)

Writes quantities in elements for a given step

Parameters:
  • step (int) – sampling step
  • elements (list of LoggedQuantity) – list of quantities to write
class rexfw.statistics.writers.StandardFileMCMCStatisticsWriter(filename, variables_to_write=[], quantities_to_write=[])[source]

Bases: rexfw.statistics.writers.AbstractFileStatisticsWriter

_format(quantity)[source]
_sort_quantities(quantities)[source]
_write_all_but_header(quantities)[source]
_write_header()[source]
_write_quantity_class_header(quantity)[source]
_write_single_quantity_stats(elements)

Writes a single line to stdout / file, e.g., all sampler step sizes which would be stored in elements

Parameters:elements (list of LoggedQuantity) – quantities to write
_write_step_header(step)[source]
write(step, elements)[source]

Writes quantities in elements for a given step

Parameters:
  • step (int) – sampling step
  • elements (list of LoggedQuantity) – list of quantities to write
class rexfw.statistics.writers.StandardFileREHeatsStatisticsWriter(outfolder)[source]

Bases: rexfw.statistics.writers.AbstractStatisticsWriter

Writes heats produced during replica exchange swap trajectories to a file.

Parameters:outfolder (str) – path to folder to write heats to
_write_single_quantity_stats(elements)

Writes a single line to stdout / file, e.g., all sampler step sizes which would be stored in elements

Parameters:elements (list of LoggedQuantity) – quantities to write
write(elements)[source]

Writes quantities in elements for a given step

Parameters:
  • step (int) – sampling step
  • elements (list of LoggedQuantity) – list of quantities to write
class rexfw.statistics.writers.StandardFileREStatisticsWriter(filename, quantities_to_write=[])[source]

Bases: rexfw.statistics.writers.AbstractFileStatisticsWriter

Writes replica exchange acceptance rates to a file.

Parameters:
  • filename (str) – path to file to write sampling statistics to
  • variables_to_write (list of str) – list of sampling variable names for which to write statistics
  • quantities_to_write (list of LoggedQuantity) – list of LoggedQuantity objects for which to write statistics
_format(quantity)[source]
_sort_quantities(quantities)[source]
_write_all_but_header(quantities)[source]
_write_header()[source]
_write_quantity_class_header(class_name)[source]
_write_single_quantity_stats(elements)

Writes a single line to stdout / file, e.g., all sampler step sizes which would be stored in elements

Parameters:elements (list of LoggedQuantity) – quantities to write
_write_step_header(step)[source]
write(step, elements)[source]

Writes quantities in elements for a given step

Parameters:
  • step (int) – sampling step
  • elements (list of LoggedQuantity) – list of quantities to write
class rexfw.statistics.writers.StandardFileREWorksStatisticsWriter(outfolder)[source]

Bases: rexfw.statistics.writers.AbstractStatisticsWriter

_write_single_quantity_stats(elements)

Writes a single line to stdout / file, e.g., all sampler step sizes which would be stored in elements

Parameters:elements (list of LoggedQuantity) – quantities to write
write(elements)[source]

Writes quantities in elements for a given step

Parameters:
  • step (int) – sampling step
  • elements (list of LoggedQuantity) – list of quantities to write