- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有 10 个气候站的降水数据,它是 DEM。
我做了一个线性回归如下:
DEM = [200, 300, 400, 500, 600, 300, 200, 100, 50, 200]
Prep = [50, 95, 50, 59, 99, 50, 23, 10, 10, 60]
X = DEM #independent variable
Y = Prep #dependent variable
slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)
但现在我想为这些站增加权重,例如:
Weight = [0.3, 0.1, 0.1, 0.1, 0.2, 0.05, 0.05, 0.05, 0.05, 0.05]
我找到了加权最小二乘法来做这件事,但我想知道它是如何工作的,为什么工作,或者它是否错误。
import numpy as np
import statsmodels.api as sm
Y = [1, 3, 4, 5, 2, 3, 4]
X = range(1, 8)
X = sm.add_constant(X)
wls_model = sm.WLS(Y, X, weights=range(1, 8))
results = wls_model.fit()
results.params
最佳答案
回答:
import numpy as np
import statsmodels.api as sm
start_time = time.time()
alist=[2,4,6]
DEM=[200,300,400,500,300,600]
PRE=[20,19,18,20,21,22,30,23]
A_DEM=[]
A_PRE=[]
W=[]
for a in alist:
A_DEM.append(DEM[a-1])
A_PRE.append(PRE[a-1])
W.append(1)
X = sm.add_constant(A_DEM)
Y = A_PRE
wls_model = sm.WLS(Y,X, weights=W).fit()
print wls_model.params[0] # intercept
print wls_model.params[1] # slope
print wls_model.rsquared #rsquared
print wls_model.summary()
而且我发现 WLS 会自动归一化。所以你可以直接添加权重。
关于python - 如何在 python 中加权站以订购最小二乘法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30722896/
我正在尝试以一种可以根据需要循环输出和输出 header 的方式编写 SQL Server 2008 查询。我已经多次以错误的方式完成这些工作,让 ColdFusion 在页面中完成艰苦的工作,但需要
为什么通用寄存器按原样排序(eax、ecx、edx、ebx)?例如,对于“inc”指令,操作码是: inc eax - 40 inc ecx - 41 inc edx - 42 inc ebx - 4
晚上好。 我需要组织一个HashMap,它是这样的: private HashMap>taskOrdered = new HashMap>(); 每个“任务”都是一个具有 3 个属性的类: 人员姓名;
这个问题在这里已经有了答案: C# - sorting by a property (3 个答案) how to sort a collection by datetime in c# (4 个答案
我有以下存储记录和错误的 XML 文档(如果需要可以重新设计)。 11/03/2010 14:12:41 1 11/03/2
关于这个主题有很多问题,仍然无法找到解决这个问题的方法。 我正在做的查询是: SELECT `b`.`ads_id` AS `ads_id`, `b`.`bod_bedrag`
我正在制作一个排名系统。但我想要的是将我得到的结果 ($kn) 从最高到最低排序。我该怎么做? include "includes/core.inc.php"; require "includes/c
我有一个这样的列表, M=[[75], [95, 64], [17, 47, 82], [18, 35, 87, 10], [20, 4, 82, 47, 65], [19, 1, 23, 75, 3
我有 5 个数学问题要解决,30 个人将尝试解决这些问题中的每一个。 我知道每个人解决某个问题的速度有多快: Person1 将能够在 5 秒内解决问题 A,在 7 秒内解决问题 B,在 20 秒内解
考虑 val animals = List("penguin","ferret","cat").toSeq val rdd = sc.makeRDD(animals, 1) 我想订购这个 RDD。我是
我有以下列表: 我的 list [[1]] [1] 11 [[2]] [1] 9 [[3]] [1] 10 我想对它进行排序。我试过了 sort(mylist) Error: mylist must
sort(v; alg::Algorithm=defalg(v), lt=isless, by=identity, rev::Bool=false, order::Ordering=Forward)
我有一个数据框,我想生成一个 geom_tile()从中绘制,但我希望图形的排序不是基于字母顺序而是基于此数据框中的变量。 structure(list(V1 = c("a", "y", "w", "
我列出 Facebook 好友是这样的: FB.api('/me/friends?fields=id,name,updated_time&date_format=U&',
我正在多个线程中的UDP上接收消息。每次接待后,我都会提出MessageReceived.OnNext(message)。 因为我使用多个线程,所以消息无序引发,这是一个问题。 如何通过消息计数器命令
我与两个实体有一对多关系: Order: int OrderId string OrderNumber ... OrderItem: int ItemId int sequence decimal Q
我正在尝试从用户将输入的数字(代码)中对结构进行排序,并且我正在使用冒泡排序。我希望程序打印按数字(代码)排序的所有数据,但它只对数字(代码)进行排序。有人可以帮我对数字(代码)中的其他元素进行排序吗
对于我的通用网格,我目前这样做是为了激活排序: Elements.OrderBy(column.SortExpression).AsQueryable(); 其中SortExpression类型为 F
给定两个 DOM 元素,比如 a 和 b,我们如何确定哪个在文档中排在第一位? 我正在对一组元素实现拖放操作。并且可以以任意顺序选择元素,但是在拖动它们时,需要以“正确”的顺序移动这些元素。 最佳答案
我正在将我们的管理系统从 PHP 迁移到 Ruby On Rails。旧系统的一部分使用 SQL 来构建客户列表,然后按最后一次联系的时间对他们进行排序: SELECT `cust
我是一名优秀的程序员,十分优秀!