{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "56b47a07",
   "metadata": {},
   "source": [
    "\n",
    "File: 01-random_parameters.py\n",
    "\n",
    "\n",
    "Michel Bierlaire\n",
    "\n",
    "Tue Aug 05 2025, 10:53:06\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e3366de6",
   "metadata": {},
   "source": [
    "The objective of this laboratory is to develop a concrete intuition about mixtures. You will be\n",
    "plotting the choice probability of a mixture of logit models as a function of a\n",
    "variable of the model."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0bf8edb7",
   "metadata": {},
   "source": [
    "We consider a simple binary logit model, with the following utility\n",
    "functions:\n",
    "\n",
    "- Alternative 1: $V_class_1 = 0$\n",
    "- Alternative 2: $V_class_2 = -\\beta x + 2 M$, where $M$ is 1 if the individual is male, 0 otherwise."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5e2caa4b",
   "metadata": {},
   "source": [
    "The exact value of $\\beta$ is not known. It is known to be distributed\n",
    "across the population, with a different distribution for men and\n",
    "women. The population contains 50\\% of men and 50\\% of women.  The\n",
    "coefficient $\\beta$ for men follows a normal distribution with mean\n",
    "$-3$ and standard deviation $2$:\n",
    "$$\n",
    "\\beta \\sim N(-3, 2^2).\n",
    "$$\n",
    "The coefficient $\\beta$ for women follows a normal distribution\n",
    "with mean $-1$ and standard deviation $3$:\n",
    "$$\n",
    "\\beta \\sim N(-1, 3^2).\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "75907011",
   "metadata": {},
   "source": [
    "First, write the formula for the choice probability for alternative 1\n",
    "in the following contexts:\n",
    "\n",
    "1. both $\\beta$ and $M$ are known,\n",
    "2. $M$ is known,\n",
    "3. $M$ is unknown."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f236f8ec",
   "metadata": {},
   "source": [
    "In order to emphasize the importance of the mixture, we compare\n",
    "the choice probability provided by the mixtures of logit, with the one\n",
    "where $\\beta$ is assumed to be fixed at its mean value, that is $-3$ for\n",
    "men, and $-1$ for women.\n",
    "Therefore, plot the choice probability for values of $x$ between 0 and 2 in\n",
    "the following contexts:\n",
    "\n",
    "1. A man, $\\beta$ unknown.\n",
    "2. A woman, $\\beta$ unknown.\n",
    "3. An individual, gender unknown, $\\beta$ unknown.\n",
    "4. A man, $\\beta$ selected at the mean value.\n",
    "5. A woman, $\\beta$ selected at the mean value.\n",
    "6. An individual, gender unknown, $\\beta$ selected at the mean value."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "af5775c0",
   "metadata": {},
   "source": [
    "*Hint*: Use the package `scipy` both to deal with randon variables with a normal distribution, and to calculate\n",
    "integrals. In this simple example, there is no need to use Monte-Carlo integration."
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 5
}
