{ "cells": [ { "cell_type": "markdown", "id": "3396690e", "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": "9a28976b", "metadata": { "execution": { "iopub.execute_input": "2026-03-26T10:47:19.802219Z", "iopub.status.busy": "2026-03-26T10:47:19.801987Z", "iopub.status.idle": "2026-03-26T10:47:19.994905Z", "shell.execute_reply": "2026-03-26T10:47:19.994272Z" } }, "outputs": [], "source": [ "from stormvogel import parametric" ] }, { "cell_type": "markdown", "id": "c72114b8", "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": "5132c171", "metadata": { "execution": { "iopub.execute_input": "2026-03-26T10:47:19.997206Z", "iopub.status.busy": "2026-03-26T10:47:19.996966Z", "iopub.status.idle": "2026-03-26T10:47:20.000883Z", "shell.execute_reply": "2026-03-26T10:47:20.000424Z" } }, "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": "b9784951", "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": "d7b8dc31", "metadata": { "execution": { "iopub.execute_input": "2026-03-26T10:47:20.002536Z", "iopub.status.busy": "2026-03-26T10:47:20.002377Z", "iopub.status.idle": "2026-03-26T10:47:20.208604Z", "shell.execute_reply": "2026-03-26T10:47:20.208032Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "
\n", "