Skip to content

Conditional distributions

this patch implements a scheme to support general conditional distributions within EventGenerators. The main changes are as follows

eventgen/distributions.py

  • added _required attribute to all SamplingDistributions
  • added logic to explicitly check whether the appropriate number of arguments have been passed to rvs, pdf, jacobian, and hessian by comparing them to _variates and _required as necessary.
    • this includes delegating to separate processes for each child after checking, called _rvs, _pdf, _jacobian, and _hessian. Child processes overwrite the _* methods instead of the * method so that the checks still work when users call the * method.
    • Note, I decided to not use generators here because they required a lot of extra work to get class attributes into them because self is not defined at compilation time and class inheritance was doing funny things with variable scopes.
  • added ParetoFlatComponentMassConditionedOnRedshift, which is the first instance of a conditioned distribution

eventgen/generators.py

  • changed instantiation to always run thru append_generator, append_transform, and append_conditional so that any sanity checks defined in those methods are used at instantiation time.
  • added properties to get the generators, transforms, and conditionals
  • added logic to check whether all the a generator or transform will produce a variate that will already be produced and whether they require a variate that has not been produced within append_* methods. In either case, an AssertionError will be raised.
  • added logic to pass both the variates and required attributes from each event to the generators and transforms within EventGenerator.generate_events and EventGenerator.pdf
  • cleaned up a bunch of the instantation logic within MonteCarloIntegrator because it is now handled within EventGenerator.append_*. We still check that all required variates will be generated for each event, though.

eventgen/transforms.py

  • changed the variable name from _generates to _variates to match the nomenclature
Edited by Reed Essick

Merge request reports

Loading