NestedLogit.calc_conditional_prob#

NestedLogit.calc_conditional_prob(U, lambdas, nest_idx, nest_name, nest_indices, alphas_nest)[source]#

Calculate conditional probability within a nest.

This implements the scaled softmax probability within a nest: P(y_i = j | j ∈ nest) = exp(U_ij / λ) / Σ_{k ∈ nest} exp(U_ik / λ)

Parameters:
UTensorVariable

Systematic utility, shape (n_obs, n_alts)

lambdasTensorVariable

Nest-specific lambda parameters

nest_idxint

Index of current nest in lambda array

nest_namestr

Name of the nest

nest_indicesdict

Mapping of nest names to alternative indices

Returns:
exp_W_nestTensorVariable

Exponentiated inclusive value for the nest, shape (n_obs,)

P_y_given_nestTensorVariable

Conditional probabilities within the nest, shape (n_obs, n_alts_in_nest)