Created
February 24, 2019 18:14
-
-
Save shotahorii/717590a3dc8f352de5d9ce441b3f26a1 to your computer and use it in GitHub Desktop.
Linearity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "### Linearity and Linear Regression\n", | |
| "- https://www.yukms.com/biostat/haga/download/archive/likelihood/Likelihood.pdf\n", | |
| "- https://www.iwanttobeacat.com/entry/2018/01/04/224110\n", | |
| "- https://www.iwanttobeacat.com/entry/2018/04/29/095125\n", | |
| "- https://qiita.com/te20/items/e91faee8f9eb9b1a869c" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "#### まず、線型性とは?" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 12, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/latex": [ | |
| "関数が線型であるというのは、以下の二つの性質を持つこと。<br><br>\n", | |
| "$$f(x+y) = f(x) + f(y)$$<br>\n", | |
| "$$f(kx) = kf(x)$$<br>\n", | |
| "kは実数<br><br>\n", | |
| "\n", | |
| "例えば、以下の関数は線型。<br><br>\n", | |
| "$$f(x)=3x$$<br>\n", | |
| "なぜなら、以下が成り立つため。<br>\n", | |
| "$$f(x+y)=3(x+y)=3x+3y=f(x)+f(y)$$<br>\n", | |
| "$$f(kx)=3kx=kf(x)$$" | |
| ], | |
| "text/plain": [ | |
| "<IPython.core.display.Latex object>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "%%latex\n", | |
| "関数が線型であるというのは、以下の二つの性質を持つこと。<br><br>\n", | |
| "$$f(x+y) = f(x) + f(y)$$<br>\n", | |
| "$$f(kx) = kf(x)$$<br>\n", | |
| "kは実数<br><br>\n", | |
| "\n", | |
| "例えば、以下の関数は線型。<br><br>\n", | |
| "$$f(x)=3x$$<br>\n", | |
| "なぜなら、以下が成り立つため。<br>\n", | |
| "$$f(x+y)=3(x+y)=3x+3y=f(x)+f(y)$$<br>\n", | |
| "$$f(kx)=3kx=kf(x)$$" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "#### では、線形回帰とは?" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 23, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/latex": [ | |
| "線形回帰とは、回帰分析の中で、yとxの関係が例えば以下のように表されるものを指す。<br><br>\n", | |
| "$$y = \\beta_0 + \\beta_1 x_1 + \\beta_2 x_2^2$$<br><br>\n", | |
| "いきなり$$x^2$$が出てきていて線型ではないように見えるが、線形回帰分析で前提とされるのは、\n", | |
| "yとxが線型関係にあることではなく、yと各パラメータ($$\\beta_0, \\beta_1, ...$$)が線型関係にあることである。<br>\n", | |
| "これは、回帰式を各パラメータ($$\\beta_0, \\beta_1, ...$$)で偏微分するとそれぞれの偏微分方程式で各パラメータ\n", | |
| "が消えるためである。これにより、各パラメータで偏微分した偏微分方程式の連立方程式を解くことで各パラメータが得られる。\n", | |
| "この連立方程式を<b>正規方程式(Normal Equation)</b>という。" | |
| ], | |
| "text/plain": [ | |
| "<IPython.core.display.Latex object>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "%%latex\n", | |
| "線形回帰とは、回帰分析の中で、yとxの関係が例えば以下のように表されるものを指す。<br><br>\n", | |
| "$$y = \\beta_0 + \\beta_1 x_1 + \\beta_2 x_2^2$$<br><br>\n", | |
| "いきなり$$x^2$$が出てきていて線型ではないように見えるが、線形回帰分析で前提とされるのは、\n", | |
| "yとxが線型関係にあることではなく、yと各パラメータ($$\\beta_0, \\beta_1, ...$$)が線型関係にあることである。<br>\n", | |
| "これは、回帰式を各パラメータ($$\\beta_0, \\beta_1, ...$$)で偏微分するとそれぞれの偏微分方程式で各パラメータ\n", | |
| "が消えるためである。これにより、各パラメータで偏微分した偏微分方程式の連立方程式を解くことで各パラメータが得られる。\n", | |
| "この連立方程式を<b>正規方程式(Normal Equation)</b>という。" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "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.5.2" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment