顯示具有 學習整理 標籤的文章。 顯示所有文章
顯示具有 學習整理 標籤的文章。 顯示所有文章

2010年12月6日 星期一

[學習] MATLAB polynomial regression

其實這也不是多複雜的功能
不過這次作業用到的關係
把這個指令稍微瞭解了一點
在這邊整理一下
[p,S,mu] = polyfit(x,y,n)
x 指的是預測變數值 independent variable
y 是被預測變數 dependent variable
n 是指polynomial 到的指數次方…{1,2,…}

得到的
p 是係數
S 是一些output例如df ss的值
mu 是標準化相關的值

此外還可以利用polyval得到預測值
pre_y = polyval(p,x)

差距的誤差: dif = y-pre_y

參考連結:
1. http://www.mathworks.com/help/techdoc/ref/polyfit.html
2. http://www.mathworks.com/help/techdoc/ref/polyval.html

2010年5月14日 星期五

[學習] Matlab 基本指令

每次一段時間過後
要寫matlab指令又要再找一次
還是整理一下在這邊好了
基本中的基本:
  1. clc : 清除command....and error windows
  2. clear : 清除所有變數
  3. clf : 清除圖形
  1. mean(x)
  2. std(x)
  3. sort(x) 參考
  4. reshape(A,m,n) 參考
  5. size(a,2) 行 1->列

[學習]_Empirical distribution function

參考 http://en.wikipedia.org/wiki/Empirical_distribution_function

最近寫231報告的時候用到的
好像無母數分析裡面常常使用
當我們不確定資料的分布狀況時

給定一組資料
可以用cdf來逼近分布的狀況
就叫做empirical distribution

ps: Matlab 中相關的指令 given x is a set of data
ecdf(x)
cdfplot(x)
http://www.mathworks.com/access/helpdesk/help/toolbox/stats/ecdf.html
http://www.mathworks.com/access/helpdesk/help/toolbox/stats/cdfplot.html

2010年3月25日 星期四

[學習] Implicit function theorem

還有一個強大的定理 Implicit function theorem
基本上就是想知道 dy/dx 但是所有的關係都是透過另一個函數連在一起的
所以有人就很聰明的發展這個定理
就算兩個變數是沒有直接相關連的
我們也可以很快知道彼此對應的影響
推導的內容也只是用到簡單的chain rule而已
但是卻真的滿好用得
記錄一下

http://en.wikipedia.org/wiki/Implicit_function_theorem

[學習] Envelope theorem

記錄一下寫作業的時候用到的兩個定理:
Envelope theorem:
當面對 min f(x,r)
想知道單一變數偏微的效果時可以使用(以外為引用沒有限制的情況下)

Consider an arbitrary maximization (or minimization) problem where the objective function f(x,r) depends on some parameters r:

f^*(\bold r) = \max_{\bold x} f(\bold x,\bold r)\,

The function f *(r) is the problem's optimal-value function — it gives the maximized (or minimized) value of the objective function f(x,r)as a function of its parameters r.

Let x*(r) be the (arg max) value of x, expressed in terms of the parameters, that solves the optimisation problem, so that f*(r)=f(x*(r),r). The envelope theorem tells us how f*(r) changes as a parameter changes, namely:

\frac{d\ f^*(\bold r)}{d\ r_i} =  \frac{\partial f(\bold x,\bold r)}{ \partial r_i} \Bigg|_{\bold x = \bold x^*(\bold r)}

That is, the derivative of f*(r) with respect to ri is given by the partial derivative of f(x,r) with respect to ri, holding x fixed, and then evaluating at the optimal choice x=x*(r).

http://en.wikipedia.org/wiki/Envelope_theorem
應該是要求 f is twice differentiable continuous function.

2010年3月20日 星期六

[學習] NP hard & NPComplete

最近有人問什麼是NP 什麼是NPComplete
就順便查了一下清楚的定義
簡單的說,
NP hard的問題就是沒有辦法找到Polynomial的演算法來解決此問題
但是在NP hard的問題中又可以分成 NP Complete 跟 Weakly NP
原因是演算法複雜度包含了兩個部分
一個是演算法迭代的operation次數
一個是演算法的digits 次數
如果兩個都是NP的話,就是NP Complete
如果演算法是Polynomial的話,但是digit有可能會爆掉
就是weakly NP

參考:
http://en.wikipedia.org/wiki/Weakly_NP-complete
http://en.wikipedia.org/wiki/NP-complete