lightcurvelynx.math_nodes.random_choice

The RandomChoiceNode allows the user to randomly select one of the values from a given list of parameters.

Classes

RandomChoiceNode

A FunctionNode that returns randomly selected parameters from a given list

Module Contents

class RandomChoiceNode(values, *, weights=None, seed=None, **kwargs)[source]

Bases: lightcurvelynx.base_models.FunctionNode

A FunctionNode that returns randomly selected parameters from a given list with replacement. This is a version of the GivenValueSampler that is designed to work with parameterized (chained) inputs.

Parameters:
  • values (list-like of parameters) – The list of input parameters from which to randomly select.

  • weights (list-like of float, optional) – The weights corresponding to each value. If not provided, all values are equally likely. Default: None

  • seed (int, optional) – The seed for the random number generator. If not provided, the node will use a random seed. Default: None

compute(graph_state, rng_info=None, **kwargs)[source]

Return the given values.

Parameters:
  • graph_state (GraphState) – An object mapping graph parameters to their values. This object is modified in place as it is sampled.

  • rng_info (numpy.random._generator.Generator, optional) – A given numpy random number generator to use for this computation. If not provided, the function uses the node’s random number generator.

  • **kwargs (dict, optional) – Additional function arguments.

Returns:

results – The result of the computation. This return value is provided so that testing functions can easily access the results.

Return type:

any