design a regress function whose coeficients satisfy certain conditions
来源:互联网 发布:电影cms系统哪个好 编辑:程序博客网 时间:2024/04/28 00:23
Problem:
Given n points (x_1, x_2, ...x_n) as independent variables, where x_i can be a value or a vector, and the dependent variables (y_1, y_2, ... y_i), design a regression that satifies:
1. f(x) = t(w) * x (assume the the attribute of x corresponding w_0 is 1)
2. sigma(w) = 1
3. w_i >= 0
3. minimize sigma(y - f(x))^2
Solution:
The solution is based on KKT condition which is a generized from langrange muptiply method.
KKT conditions of this question:
1. delta(siagma(y - f(x))^2 + a * delta(w) + sigma(b_i * delta(w_i)) = 0
2. sigma(w) = 1
solve about equotions, we get:
b_i = 0
rbind(
cbind(2 * t(X) *X, c(1, ....),
c(w, 1)
) * c(w, a) = 2 * t(X) * Y
R code: ( assume x is a vector, whose first element is 1 correponding w_0)
regress <- function(x, y) { A <- 2 * t(x) %*% x B <- rep(1, nrow(A)) C <- 2 * t(x) %*% y D <- c(rep(1, nrow(A)), 0) left <- rbind(cbind(A, B), D) coef <- solve(left, c(C, 1)) coef[1:length(coef) - 1]}
- design a regress function whose coeficients satisfy certain conditions
- How do you design a rand7 function
- Select a table of certain webpage
- reseting remote to a certain commit
- A. Whose sentence is it?
- [Python]Function Design Receipe
- Find the smallest window of a certain sequence
- Display certain line(s) from a text file in Linux.
- A function returns function
- codeforces 312A.Whose sentence is it?
- CodeForces 312A Whose sentence is it?
- A function
- find all pairs of elements in a balanced BST that sum to a certain number
- How does the certain version of a certain brower support the JavaScript Standard?(come from Javascript:The definitive guide, 4th
- Multi select elements which sums upto a certain number from an array
- Multi select elements which sums upto a certain number from an array(II)
- Repeat Part of the Regex a Certain Number of Times (重复匹配中的部分)
- How can I dump only certain entries of a table based on my condition?
- PHP中的魔术方法总结 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep
- C语言sscanf和sprintf的用法及实例
- 泛型编程与STL(二):函数对象
- Linux字符设备驱动(三)
- Android教程(五)-- Button控件配合Toast控件的使用
- design a regress function whose coeficients satisfy certain conditions
- rqnoj-614
- JDK 动态代理对异常的处理及InvocationTargetException异常解析
- linux --dup dup2 文件描述符重定向函数--输入输出重定向
- 站内消息系统数据表怎么设计
- java文件读写操作大全
- 省油还是费油 涡轮增压到底有多"神"?
- WINCE data abort 内核调试错误分析
- jsp中文乱码终极解决方法