larch.Model.probability#

Model.probability(x=None, *, start_case: int | None = None, stop_case: int | None = None, step_case: int | None = None, return_format: Literal['dataframe', 'names', 'idce', 'idca', 'dataarray', None] = False, include_nests=False)#

Compute values for the probability function embodied by the model.

Parameters:
  • x (array-like or dict, optional) – New values to set for the parameters before evaluating the probability. If given as array-like, the array must be a vector with length equal to the length of the parameter frame, and the given vector will replace the current values. If given as a dictionary, the dictionary is used to update the parameters.

  • start_case (int, default 0) – The first case to include in the probability computation. To include all cases, start from 0 (the default).

  • stop_case (int, default -1) – One past the last case to include in the probability computation. This is processed as usual for Python slicing and iterating, and negative values count backward from the end. To include all cases, end at -1 (the default).

  • step_case (int, default 1) – The step size of the case iterator to use in probability calculation. This is processed as usual for Python slicing and iterating. To include all cases, step by 1 (the default).

  • return_format ({"dataframe", "names", "idca", "dataarray", None}, default None) –

    Return the result in the indicated format. - ‘dataframe’ gives a pandas DataFrame indexed by cases and with

    alternative codes as columns.

    • ’names’ gives a pandas DataFrame indexed by cases and with

      alternative names as columns.

    • ’idca’ gives a pandas DataFrame containing a single columns and

      with a two-level multi-index giving cases and alternatives.

    • ’dataarray’ gives a two-dimension DataArray, with cases and

      alternatives as dimensions.

Returns:

array or DataFrame or DataArray