{ "cells": [ { "cell_type": "markdown", "id": "1a22c16b", "metadata": {}, "source": [ "# Parametric and Interval Models\n", "In this notebook, we will show how to create and work with parametric and\n", "interval models.\n", "## Parametric Models\n", "\n", "Stormvogel represents parametric transition values as **sympy expressions**.\n", "Any polynomial or rational function over `sympy.Symbol` parameters is a valid\n", "transition value, which means you can write them using ordinary Python\n", "arithmetic." ] }, { "cell_type": "code", "execution_count": 1, "id": "590744a2", "metadata": { "execution": { "iopub.execute_input": "2026-10-22T15:30:24.365015Z", "iopub.status.busy": "2026-10-22T15:30:24.364837Z", "iopub.status.idle": "2026-10-22T15:30:24.606528Z", "shell.execute_reply": "2026-10-22T15:30:24.605906Z" } }, "outputs": [], "source": [ "import sympy as sp" ] }, { "cell_type": "markdown", "id": "1dc2a8f6", "metadata": {}, "source": [ "For example, a polynomial in two variables:" ] }, { "cell_type": "code", "execution_count": 2, "id": "9fa309ea", "metadata": { "execution": { "iopub.execute_input": "2026-10-22T15:30:24.608768Z", "iopub.status.busy": "2026-10-22T15:30:24.608539Z", "iopub.status.idle": "2026-10-22T15:30:24.637792Z", "shell.execute_reply": "2026-10-22T15:30:24.637252Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x**2 + y**2\n", "6*z**3 + z + 2\n", "(x**2 + y**2)/(6*z**3 + z + 2)\n" ] } ], "source": [ "x, y, z = sp.symbols(\"x y z\")\n", "\n", "polynomial1 = x**2 + y**2\n", "print(polynomial1)\n", "\n", "polynomial2 = 6 * z**3 + z + 2\n", "print(polynomial2)\n", "\n", "rational_function = polynomial1 / polynomial2\n", "print(rational_function)" ] }, { "cell_type": "markdown", "id": "9c7d97c5", "metadata": {}, "source": [ "To create a parametric model (e.g. pMC or pMDP) we simply use these sympy\n", "expressions as transition probabilities. As an example, we build a\n", "parametric Knuth–Yao dice: a coin with success probability `x` is flipped\n", "repeatedly to simulate a six-sided die." ] }, { "cell_type": "code", "execution_count": 3, "id": "513a0a38", "metadata": { "execution": { "iopub.execute_input": "2026-10-22T15:30:24.639748Z", "iopub.status.busy": "2026-10-22T15:30:24.639551Z", "iopub.status.idle": "2026-10-22T15:30:25.150936Z", "shell.execute_reply": "2026-10-22T15:30:25.150397Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "
\n", "