Module vickrey.likelihood.likelihood
Functions concerning the computation of the likelihood.
Functions
def likelihood(travel_time, t_a, mu_b, mu_g, mu_t, sigma, sigma_t)
-
Expand source code
def likelihood(travel_time, t_a, mu_b, mu_g, mu_t, sigma, sigma_t): """Find the likelihood of a single data point. Given the parameters, find the likelihood of a point realizing a minimum. Beta, gamma and t* are assumed to be normally distributed. Args: travel_time: Instance of the TravelTime class the likelihood is computed on t_a: Time point of which the likelihood is computed mu_b: Mean of the beta parameter, relative to the early arrival penalty mu_g: Mean of the gamma parameter, relative to the late arrival penalty mu_t: Mean of the t* parameter, relative to the desired arrival time sigma: Variance of the beta and gamma distributions, that are assumed to share the same variance sigma_t: Variance of the t* parameter Returns: likelihood: float number representing the likelihood of an optimal arrival being equal to t_a """ lik_early = _early_lik(travel_time, t_a, mu_b, mu_g, mu_t, sigma, sigma_t) lik_late = _late_lik(travel_time, t_a, mu_b, mu_g, mu_t, sigma, sigma_t) likelihood_kink = _ot_lik( travel_time, t_a, mu_b, mu_g, mu_t, sigma, sigma_t ) likelihood_internal = lik_early + lik_late likelihood = likelihood_kink + likelihood_internal return jnp.maximum(likelihood, 1e-31)
Find the likelihood of a single data point.
Given the parameters, find the likelihood of a point realizing a minimum. Beta, gamma and t* are assumed to be normally distributed.
Args
travel_time
- Instance of the TravelTime class the likelihood is computed on
t_a
- Time point of which the likelihood is computed
mu_b
- Mean of the beta parameter, relative to the early arrival penalty
mu_g
- Mean of the gamma parameter, relative to the late arrival penalty
mu_t
- Mean of the t* parameter, relative to the desired arrival time
sigma
- Variance of the beta and gamma distributions, that are assumed to share the same variance
sigma_t
- Variance of the t* parameter
Returns
likelihood()
- float number representing the likelihood of an optimal arrival being equal to t_a
def total_liks(travel_time, t_as)
-
Expand source code
def total_liks(travel_time, t_as): """Likelihood of each data point in a set of arrival times. Args: travel_time: Travel time function. t_as: Dataset of arrival times. Returns: mapped_lik: Function mapping a parameter set to the array of likelihoods. """ def mapped_lik(mu_b, mu_g, mu_t, sigma, sigma_t): @jit def lik_restr(t_a): return likelihood( travel_time, t_a, mu_b, mu_g, mu_t, sigma, sigma_t ) return vmap(lik_restr)(t_as) return mapped_lik
Likelihood of each data point in a set of arrival times.
Args
travel_time
- Travel time function.
t_as
- Dataset of arrival times.
Returns
mapped_lik
- Function mapping a parameter set to the array of likelihoods.
def total_log_lik(travel_time, t_as)
-
Expand source code
def total_log_lik(travel_time, t_as): """Total log likelihood of a set of arrival times. Args: travel_time: Travel time function. t_as: Dataset of arrival times. Returns: mapped_lik: Function mapping a parameter set to the value of the total likelihood. """ def mapped_lik(mu_b, mu_g, mu_t, sigma, sigma_t): def lik_restr(t_a): return likelihood( travel_time, t_a, mu_b, mu_g, mu_t, sigma, sigma_t ) return jnp.sum(jnp.log(vmap(lik_restr)(t_as)), axis=0) return mapped_lik
Total log likelihood of a set of arrival times.
Args
travel_time
- Travel time function.
t_as
- Dataset of arrival times.
Returns
mapped_lik
- Function mapping a parameter set to the value of the total likelihood.