如何计算权重以最小化方差? [英] How to calculate weight to minimize variance?

查看:1509
本文介绍了如何计算权重以最小化方差?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出了几个向量:

x1 = [3 4 6]
x2 = [2 8 1]
x3 = [5 5 4]
x4 = [6 2 1]

我想找到每个项目的权重w1,w2,w3,并获得每个向量的加权总和:yi = w1*i1 + w2*i2 + w3*i3.例如y1 = 3*w1 + 4*w2 + 6*w3 使这些值(y1,y2,y3,y4)的方差最小.

I wanna find weight w1, w2, w3 to each item, and get the weighted sum of each vector: yi = w1*i1 + w2*i2 + w3*i3. for example, y1 = 3*w1 + 4*w2 + 6*w3 to make the variance of these values(y1, y2, y3, y4) to be minimized.

注意:w1,w2,w3应该> 0,并且w1 + w2 + w3 = 1

notice: w1, w2, w3 should > 0, and w1 + w2 + w3 = 1

我不知道应该是什么样的问题...以及如何在python或matlab中解决它?

I don't know what kind of problems it should be... and how to solve it in python or matlab?

推荐答案

您可以从构建损失函数开始,该函数说明方差和w的约束.平均值是m = (1/4)*(y1 + y2 + y3 + y4).则方差为(1/4)*((y1-m)^2 + (y2-m)^2 + (y3-m)^2 + (y4-m)^2),约束条件为a*(w1+w2+w3 - 1),其中a是拉格朗日乘数.在我看来,这个问题看起来像是具有凸约束的凸优化,因为损失函数相对于目标变量(w1,w2,w3)是二次函数,并且约束是线性的.您可以根据所提供的约束条件寻找投影梯度下降算法.在这里查看 http://www.ifp.illinois.edu/~angelia /L5_exist_optimality.pdf 总体上,没有直接的解析方法可以解决此类问题.

You can start with building a loss function stating the variance and the constraints on w's. The mean is m = (1/4)*(y1 + y2 + y3 + y4). The variance is then (1/4)*((y1-m)^2 + (y2-m)^2 + (y3-m)^2 + (y4-m)^2) and the constraint is a*(w1+w2+w3 - 1) where a is the Lagrange multiplier. The problem looks like to me a convex optimisation with convex constraints since the loss function is quadratic with respect to target variables (w1,w2,w3) and the constraints are linear. You can look for projected gradient descent algorithms which respect to the constraints provided. Take a look to here http://www.ifp.illinois.edu/~angelia/L5_exist_optimality.pdf There are no straightforward analytic solutions to such kind of problems in general.

这篇关于如何计算权重以最小化方差?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆