pdf

Module Contents

class pdf.SciPyPdf(pdf)
__init__(pdf)
sample()

Get a sample from the PDF

Returns:A sample from the PDF
Return type:float
mean()

float: The mean of the PDF

variance()

float: The variance of the PDF

__eq__(other)
__repr__()
class pdf.GaussianPdf(mean, variance)

A PDF representing a Gaussian distribution

pdf

norm – The Gaussian pdf object

Parameters:pdf (norm) – The Gaussian pdf object
__init__(mean, variance)
from_dict(dict_in)

Creates a GaussianPdf from a dictionary

Parameters:dict_in (dict) – The dict to create the PDF from. Must contain keys for ‘mean’ and ‘variance’
Returns:The constructed Gaussian PDF
Return type:GaussianPdf
to_dict()

Gets a dictionary representation of this PDF

Returns:The dictionary representation of this PDF
Return type:dict
class pdf.DeterministicPdf(value)

A PDF representing a Gaussian distribution

pdf

float – The exact value to be returned by the sample() function

Parameters:value (float) – The exact value to be returned by the sample() function
__init__(value)
sample()

Get a sample from the PDF. Will always return the value passed into the constructor.

Returns:The value passed into the constructor
Return type:float
mean()

float: The mean of the PDF. Always equal to the value passed into the constructor

variance()

float: The variance of the PDF. Will always return 0

__eq__(other)
from_dict(dict_in)

Creates a DeterministicPdf from a dictionary

Parameters:dict_in (dict) – The dict to create the PDF from. Must contain keys for ‘mean’
Returns:The constructed deterministic PDF
Return type:DeterministicPdf
to_dict()

Gets a dictionary representation of this PDF

Returns:The dictionary representation of this PDF
Return type:dict
class pdf.PdfFactory

Factory to construct PDFs from dictionaries

create(pdf_type, parameters)

Create a PDF

Parameters:
  • pdf_type (str) – The type of PDF to construct. Must match an entry in the pdf_registry
  • parameters (dict) – The parameters from which to construct the PDF from.
Returns:

The constructed PDF

class pdf.TimeUnits

Enum representing possible units of time

to_timedelta(value)

Converts a TimeUnits and a value to a timedelta

Parameters:
  • units (TimeUnits) – The units to use with the timedelta
  • value (float) – The value to use in the timedelta
Returns:

The timedelta with the given units and value

Return type:

timedelta

from_string(value)

Converts a string to a TimeUnits

Parameters:value (str) – The string to convert
Returns:The converted timeunit
Return type:TimeUnits
Raises:ValueError – If no matching string is found.
class pdf.DurationPdf(pdf, units=None)

A probability density function over a time duration

pdf

A probability density function object which provides a mechanism for sampling via a sample() method

units

TimeUnits – The units to use for the duration

Parameters:
  • pdf – A probability density function object
  • units (TimeUnits, optional) – The units to use for the duration. Defaults to TimeUnits.seconds
__init__(pdf, units=None)
mean()

timedelta: The mean value of this PDF

sample(minimum=None)

Get a sample from the distribution

Parameters:minimum (timedelta) – The minimum duration
Returns:A sample from the distribution
Return type:timedelta
__eq__(other)
class pdf.DatePdf(mean_datetime, pdf, units=None)

A probability density function over a datetime.

mean_datetime

datetime – A datetime to use as the mean value

pdf

A probability density function object which provides a sampling mechanism via a sample() method

units

TimeUnits – The units to use for the pdf samples

Parameters:
  • mean_datetime (datetime) – A datetime to use as the mean value
  • pdf – A probability density function object
  • units (TimeUnits, optional) – The units to use for pdf samples. Defaults to TimeUnits.seconds
__init__(mean_datetime, pdf, units=None)
mean()

timedelta: The mean value of this PDF

sample()

Get a sample from the distribution

Returns:A sample from the distribution
Return type:datetime
__eq__(other)