You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
167 lines
14 KiB
Plaintext
167 lines
14 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"%matplotlib inline\n",
|
|
"\n",
|
|
"from __future__ import division, print_function\n",
|
|
"from sympy import Symbol, diff, solve, lambdify, simplify\n",
|
|
"import matplotlib.pyplot as plt\n",
|
|
"import numpy as np"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Model parameters: We look for a line y = b1*x + b2.\n",
|
|
"b1 = Symbol('b1')\n",
|
|
"b2 = Symbol('b2')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Data points\n",
|
|
"data = [(1,14), (2, 13), (3, 12), (4, 10), (5,9), (7,8), (9,5)]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Function to minimize: S = 185*b1**2 + 62*b1*b2 - 524*b1 + 7*b2**2 - 142*b2 + 779\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# S is the function to minimize:\n",
|
|
"#\n",
|
|
"# For each data point the vertical error/residual is x*b1 + b2 - y. We want to\n",
|
|
"# minimize the sum of the squared residuals (least squares).\n",
|
|
"S = sum((p[0] * b1 + b2 - p[1]) ** 2 for p in data)\n",
|
|
"S = simplify(S)\n",
|
|
"print(\"Function to minimize: S = {}\".format(S))\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"S is minimal for b1 = -367/334, b2 = 5013/334\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Minimize S by setting its partial derivatives to zero.\n",
|
|
"d1 = diff(S, b1)\n",
|
|
"d2 = diff(S, b2)\n",
|
|
"solutions = solve([d1, d2], [b1, b2])\n",
|
|
"print(\"S is minimal for b1 = {}, b2 = {}\".format(solutions[b1], solutions[b2]))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Fitted line: y = -367*x/334 + 5013/334\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Construct fitted line from the solutions\n",
|
|
"x = Symbol('x')\n",
|
|
"fitted_line = solutions[b1] * x + solutions[b2]\n",
|
|
"print(\"Fitted line: y = {}\".format(fitted_line))\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Construct something we can plot with matplotlib\n",
|
|
"fitted_line_func = lambdify(x, fitted_line, modules=['numpy'])\n",
|
|
"x_plot = np.linspace(min(p[0] for p in data),\n",
|
|
" max(p[0] for p in data), 100)\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHd9JREFUeJzt3Xucz2X+//HHi1EhKrGtxUbrh2mcm+SQ0s5mYyPSpra2\nWt1otavUKlpFpRKtiq2kWKUiSsVGSienmAyRw2jbfjaJ1sipkpDr+8f1mVaiOXw+n7k+h+f9dn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rZL76WeCXZvZ02Eiec25T5PctwIv4+c7QNgIbD/rp6nl8wSeKTsBy59x/QweJ+BWw3jlX4Jzb\nB7wAtA2cCQDn3ATnXEvn3Fn46eO4zJ+DCr3UIjcfJwD5zrn7Q+cpZGY1zOz4yMcV8f/Q14VNBc65\nW5xztZ1zdfE/qr/pnAs+gjKzypGb2kSmNDrif0wOyjn3GfCJmTWMvJQDBL3hfohLSZDplogNQGsz\nqxT5bzMHf18rODP7SeT3nwMXEse/t4Q/JNrMpgAdgOpmthEY6pybEDYV4EecvwdWRearAf7qnJsd\nMBNATeDJyAqEcsA051zCLBFMQCcBL/oOIAOY7JybEzbSd/oBz0SmN/4/8IfAeQCIzAWfC1wTOksh\n51yumT0PLMdPabxH4jw1Ot3MTgT2AX9yzm2P14USftmiiIgUj6ZcRERShApdRCRFqNBFRFKECl1E\nJEWo0EVEUoQKXUQkRajQRURShApdRCRF/B+mBSGejRvCBwAAAABJRU5ErkJggg==\n",
|
|
"text/plain": [
|
|
"<matplotlib.figure.Figure at 0x7fdb7f6c8b70>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"# Plot data points and fitted line\n",
|
|
"plt.scatter([p[0] for p in data], [p[1] for p in data], marker=\"+\")\n",
|
|
"plt.plot(x_plot, fitted_line_func(x_plot), 'r')\n",
|
|
"plt.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.6.2"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 1
|
|
}
|