shortcuts/notebooks/deno_tinygo_wasm.ipynb

83 lines
15 KiB
Plaintext
Raw Normal View History

2024-09-29 12:14:44 +00:00
{
"cells": [
{
"cell_type": "code",
2024-09-29 18:27:50 +00:00
"execution_count": 1,
2024-09-29 12:14:44 +00:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-09-29 18:27:50 +00:00
"Stats initialized\n",
2024-09-29 12:14:44 +00:00
"\n",
"Linear Regression Line:\n",
2024-09-29 18:27:50 +00:00
"\tEstimated offset is: 1.474039\n",
"\tEstimated slope is: 3.000136\n",
"\tR^2 is: 0.999989\n"
2024-09-29 12:14:44 +00:00
]
}
],
"source": [
"import stats from \"https://l12.xyz/x/shortcuts/raw/stat/mod.ts\";\n",
"\n",
"const xs = [];\n",
"const ys = [];\n",
"\n",
"for (let i = 0; i < 100; i++) {\n",
2024-09-29 14:32:23 +00:00
" xs.push(i);\n",
" ys.push((1 + 3 * i) + Math.random());\n",
2024-09-29 12:14:44 +00:00
"}\n",
"\n",
"const linreg = stats.LinearRegression(xs, ys, [], false);\n",
"const r = stats.RSquared(xs, ys, [], linreg.alpha, linreg.beta);\n",
"\n",
"console.log(\"\\nLinear Regression Line:\");\n",
"console.log(\"\\tEstimated offset is: \", linreg.alpha.toFixed(6));\n",
"console.log(\"\\tEstimated slope is: \", linreg.beta.toFixed(6));\n",
2024-09-29 14:32:23 +00:00
"console.log(\"\\tR^2 is: \", r.toFixed(6));"
2024-09-29 12:14:44 +00:00
]
2024-09-29 18:27:50 +00:00
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"![name](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkAAAAGACAIAAADK+EpIAAAmjUlEQVR4nOzde1xVZd738WtvNgKCnERAUINU8ITgoGJqNiZmHtIZ0UJLU7PsTnN00rLRGqe08nBnivcMjo4yORo6ZKaYR4ReKXkgxVTExAQBRUDOIIe9Wc9rWnPvmwexKW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EEO+9996lS5fmz5+vKMq7775rMpkURXn77be7du2qDhseHj5u3LjS0tKKiopnn33Wzc0tLy9PUZQ9e/YIIU6ePFlvo/bs2ePm5lZUVKQoSlFRkaenZ1RUlNo1ZsyYl19++V6/jT/84Q/qR4Nvvvnm1q1b716htra2S5cuU6ZMMS8ZPHhwSUmJoigrV66sqKhQFGXdunUuLi5qb91DiMeOHRNCqFUpiuLj4xMZGakoSkJCQps2bQoKChRFee+99/r06aNu/oQJE9Q1P/roo/t6bgGLYA8MD5bz588fq6O8vLzB1aqrq3Nzc48ePSqEeP75552dneutsHnz5n79+nXo0EEIYWNjExYWtmXLFiHExYsXDQaDj4+PEMLDw8PBwUHdz1CNGjWqW7duH374oRBiyZIlev2//kC6du1qPponhGjTpo2Dg4Odnd1vf/vboqIiNzc3IcSYMWPUvKxXxt/+9rdhw4Y5OTkJIZycnEaPHq2W8R+99dZbXbt2ffHFF5OSkp577rm7V9DpdK+++urOnTvz8vLU7Ozdu3ebNm2EEAsXLrSzs1MrLywsbHC/sEH/+Mc/HnnkERcXFyHEgAEDkpOTy8vLq6urz5w5c+XKFSHE7373u584FNAEOKEWD5bJkyf/+te/Njejo6MbXO2JJ54ICwsbPnx4nz59fve7302dOrXeCunp6e7u7uZm+/bt1bM/AgICampqrl275uvre/PmzbKysoCAgAanOHz48I4dOxwcHNT37rvVPR9dp9OpaXd3GUOGDKlbhron9B/Z2tq+8847kyZN2rRp073WmT59+ltvvbVx48Y//OEPf/3rX1977TV1+fHjx6Oiolq3bp2dna3W9lNmFEJcv379ypUr06ZNE0JUVFT07t07Pz//1VdfPXjwYPfu3YcPH7548eLBgwf/xNEASyPAICVra+vo6Og//elP69evnz59usFgmDx5ct0V7O3ty8rKzM3KykpXV1edTte7d+8lS5aMGTPmscceu3Tp0sqVKx955JG7xz916tRvf/vblJSUTp06/eMf/zh+/Pj91Wlvb19VVWVuVlVVqXtsP4W6J6TuVDWoTZs2M2bMiIyMnDVrVm5ubo8ePYQQV65cefzxx8+ePdujR4+DBw9++umnP71aOzs7f3//qKioesvPnDlz7Nix9957b9iwYRcvXuzSpctPHxOwHA4hQkrnzp27c+eOv79/RETEiBEjTp06pS5XT5EQQgQGBtY9NpiamqruaVVUVBw/fjwhIWHt2rXx8fELFy5scPzTp0+7urp26tTpF9ZZr4xLly7da4fv/sydOzc7Ozs8PHz69OnqkjNnzlhbW3fv3t186uDdJxBaW1sLIUpKSuot9/f3T0lJqXfI8euvvxZCDB48eO/evfb29snJyY1YP/BLEGB4UFRUVJj/q6qpqTEajdXV1eav36qf3Aohzp49u3LlyqqqqvT09JSUlMcee0wI4efnl5iY+M0336Snp7/yyit37tzZvHmz0Wg8duzYnj173n//ffWzooSEhEmTJk2ePHnixIkzZ848cODA3e/13bp1y8zM3LRpU1xcnPrF6noF1Ht8d1O1cOHC8+fP79u3z2g07t279+zZs0uWLDFvXd2ds7upZwmq/70XX1/fp556KjU11Xx+oL+/f3l5+X//938nJCSop5aYyzP/18/Pz8bGZsmSJQcOHNi4caN66ocQYvbs2YWFhc8///xXX3117ty5uLg4IcSWLVv2799vMpkSExOrq6v79ev3n55JoIlYLV26VOsaAHHo0KHjx48PGTIkKyvLaDR27ty5sLBw9erV/v7+Xl5eiYmJgYGB69ev79mzZ1lZWW1tbVBQ0DfffLNt27YTJ07MnTv3N7/5jfrenZ6efvHixR49evj4+Dz//PMJCQlbt24tLy9/5513goKC1Hf8S5cudezY0dnZ2dHRMS0tbdmyZRMnTty1a1dISMjVq1ddXV09PDwefvhhb2/vxMREk8n04osv2tjYZGRklJWVFRUVubi4FBcX63S6o0ePDhw48MyZMwEBAREREcHBwYWFhV26dHF0dDRvl4uLy6RJk2JjY7dv324wGD744IPOnTsLIbZt22ZjY+Po6JiUlNSzZ09bW9t6v5DVq1dnZGQMGTIkIyMjJSWlf//+9/rV+fr69u7du0+fPmrT09PT39//5MmT5eXls2bNcnBwSE1N1ev1R48eHTx48JkzZ3x9fd3d3fv375+amlpYWBgaGvrwww/n5+d36tTJx8dn8uTJ6enpR48evX79emBgoLe3d9u2bfft27d9+/b09PR169Z169bNYq8C4OfR8f1EtChRUVHHjx/fuHGj2qytrXV2dt67d6+6DwdAIhxCRMuSlJRkb29vbn7xxReurq7qN5cByIU9MLQsubm5v//972tqahwcHKx+sHz5cldXV63rAvCzEWAAAClp/z2wW7duqddEqLc8ICDg8uXLd3+4LYSwU5RBP5yWdk2vv9rQt0d/isrKSk9Pz9TU1NatW9/fCGgUt2/f7tWrV0FBQYNXtm0UlZWVgYGBp0+fttD4eHBs2bJl1qxZDb5vNJbKyspVq1ZxUZIfFxsbGxYWZrk/avWJ0D7AvvrqKyHEhAkT6i2/cOGCn5+f+t3MetqXl//58GEhxD/9/LY3tMJPkZWVlZSUVFJSQoBpq7CwMCcnZ+DAgXUvnNG4vv3226SkJAsNjgfK1atXa2pqRo8ebbkpdu/efa+Ls8AsPT29u
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import plot from \"../plot/mod.ts?5\";\n",
"\n",
"plot.DrawHist(ys, 16, { title : \"Histogram of Y values\" });\n"
]
2024-09-29 12:14:44 +00:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Deno",
"language": "typescript",
"name": "deno"
},
"language_info": {
"codemirror_mode": "typescript",
"file_extension": ".ts",
"mimetype": "text/x.typescript",
"name": "typescript",
"nbconvert_exporter": "script",
"pygments_lexer": "typescript",
"version": "5.6.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}