{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "b8e434bf", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use lets-plot" ] }, { "cell_type": "code", "execution_count": 2, "id": "57bc3477", "metadata": {}, "outputs": [], "source": [ "fun generateDataMap(n: Int = 15, a: Double = 1.0): Map> {\n", " val rand = java.util.Random(42)\n", " val x = List(2 * n + 1) { i -> a * (i - n).toDouble() / n }\n", " val tMin = x.map { a * a - it.pow(2) - abs(rand.nextGaussian()) }\n", " val tMax = x.map { a * a - it.pow(2) + abs(rand.nextGaussian()) }\n", " return mapOf(\"day\" to (1..x.size).toList(), \"minTemp\" to tMin, \"maxTemp\" to tMax)\n", "}\n", "\n", "val dataMap = generateDataMap(a = 2.0)" ] }, { "cell_type": "code", "execution_count": 3, "id": "d76818b0", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "letsPlot(dataMap) +\n", " geomRibbon() { x = \"day\"; ymin = \"minTemp\"; ymax = \"maxTemp\" } +\n", " xlab(\"time\") + ylab(\"temperature\")" ] } ], "metadata": { "kernelspec": { "display_name": "Kotlin", "language": "kotlin", "name": "kotlin" }, "language_info": { "codemirror_mode": "text/x-kotlin", "file_extension": ".kt", "mimetype": "text/x-kotlin", "name": "kotlin", "nbconvert_exporter": "", "pygments_lexer": "kotlin", "version": "1.8.20" } }, "nbformat": 4, "nbformat_minor": 5 }