shortcuts/notebooks/deno_tinygo_wasm.ipynb

60 lines
1.4 KiB
Plaintext
Raw Normal View History

2024-09-29 12:14:44 +00:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Linear Regression Line:\n",
"\tEstimated offset is: 1.480586\n",
"\tEstimated slope is: 2.999774\n",
"\tR^2 is: 0.999991\n"
]
}
],
"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",
" xs.push(i);\n",
" ys.push((1 + 3 * i) + Math.random());\n",
"}\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",
"console.log(\"\\tR^2 is: \", r.toFixed(6));\n"
]
}
],
"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
}