{ "cells": [ { "cell_type": "markdown", "id": "454725c9", "metadata": {}, "source": [ "# Parametric models\n", "Instead of setting numeric values as transition probabilities, we may also use parameters, polynomials or even rational functions in multiple variables." ] }, { "cell_type": "code", "execution_count": 1, "id": "27c5f14f", "metadata": { "execution": { "iopub.execute_input": "2025-11-05T16:14:24.905072Z", "iopub.status.busy": "2025-11-05T16:14:24.904857Z", "iopub.status.idle": "2025-11-05T16:14:25.281250Z", "shell.execute_reply": "2025-11-05T16:14:25.280719Z" } }, "outputs": [], "source": [ "from stormvogel import parametric" ] }, { "cell_type": "markdown", "id": "3a715820", "metadata": {}, "source": [ "Polynomials are represented as dictionaries where the keys are the exponents and the values are coefficients. In addition, we must also supply a list of variable names. Rational functions are then represented as a pair of two polynomials (numerator and denominator)." ] }, { "cell_type": "code", "execution_count": 2, "id": "29c8793f", "metadata": { "execution": { "iopub.execute_input": "2025-11-05T16:14:25.283117Z", "iopub.status.busy": "2025-11-05T16:14:25.282890Z", "iopub.status.idle": "2025-11-05T16:14:25.286735Z", "shell.execute_reply": "2025-11-05T16:14:25.286312Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x^2 + y^2\n", "2.0*1 + z + 6.0*z^3\n", "(x^2 + y^2)/(2.0*1 + z + 6.0*z^3)\n" ] } ], "source": [ "polynomial1 = parametric.Polynomial([\"x\",\"y\"])\n", "polynomial1.add_term((2,0),1)\n", "polynomial1.add_term((0,2),1)\n", "\n", "print(polynomial1)\n", "\n", "polynomial2 = parametric.Polynomial([\"z\"])\n", "polynomial2.add_term((0,),2)\n", "polynomial2.add_term((1,),1)\n", "polynomial2.add_term((3,),6)\n", "\n", "print(polynomial2)\n", "\n", "rational_function = parametric.RationalFunction(polynomial1, polynomial2)\n", "\n", "print(rational_function)" ] }, { "cell_type": "markdown", "id": "1efd5dfc", "metadata": {}, "source": [ "To create a parametric model (e.g. pmc or pmdp) we simply have to set such a value as a transition probability. As an example, we provide the knuth yao dice, but with parameters instead of concrete probabilities." ] }, { "cell_type": "code", "execution_count": 3, "id": "85ed0ed2", "metadata": { "execution": { "iopub.execute_input": "2025-11-05T16:14:25.288304Z", "iopub.status.busy": "2025-11-05T16:14:25.288114Z", "iopub.status.idle": "2025-11-05T16:14:25.469865Z", "shell.execute_reply": "2025-11-05T16:14:25.469284Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "
\n", "