如何找到方程组的不同点? [英] How can I find the different points of a system of equations?

查看:44
本文介绍了如何找到方程组的不同点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须解决这个方程组:

I've got to solve this system of equations:

aQ + bP = c
dQ + eP = f

aQ + bP = c
dQ + eP = f

我必须找到 100 个 Q 和 P 值来解决具有以下分布的 100 个随机抽取系数的系统:

I have to find 100 values Q and P that solve the systems with 100 randomly drawn coefficients from the following distributions:

a ~ N( 100; 10)

a ~ N( 100; 10)

b ~ N(-1;0.1)

b ~ N(-1;0.1)

c ~ N(10;1)

c ~ N(10;1)

d ~ N(10;0.1)

d ~ N(10;0.1)

e ~ N(100;10)

e ~ N(100;10)

f ~ N(10;0.1)

f ~ N(10;0.1)

我做了以下事情:

a<-rnorm(100,mean=100,sd=10)
b<-rnorm(100,mean=-1,sd=.1)
c<-rnorm(100,mean=10,sd=1)
d<-rnorm(100,mean=10,0.1)
e<-rnorm(100,mean=100,sd=10)
f<-rnorm(100,mean=10,0.1)

然后我做了矩阵:

O <- matrix(data=c(a,b,c),1,1)
P<- matrix(c(d,e,f),1,1)

最后解决了:

solve(O,P)

我的问题是我正在尝试获得 100 个解决方案,但此代码仅返回一个解决方案.获得 Q 和 P 的 100 个值后,我需要绘制包含所有值的图.

My problem is that I'm trying to get 100 solutions but this code returns just one solution. After obtaining the 100 values for Q and P I need to make a plot with all of the values.

推荐答案

您可以使用 replicate 重复求解您的系统,每次使用不同的随机抽取系数:

You can use replicate to repeatedly solve your system, each time using a different random draw for the coefficients:

QP <- t(replicate(100, solve(rbind(c(rnorm(1, 100, 10), rnorm(1, -1, 0.1)),
                                   c(rnorm(1, 10, .1), rnorm(1, 100, 10))),
                             c(rnorm(1, 10, 1), rnorm(1, 10, 0.1)))))
colnames(QP) <- c("Q", "P")
plot(QP)

这篇关于如何找到方程组的不同点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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