web123456

dlut-KFQ probability on board 2

Random numbers are random, you have to run aside to make the data different! ! !

1. The code is as follows:

x=runif(1000,5,10)

y=4*x-6

print(mean(x))

[1] 7.431709

print(mean(y))

[1] 23.72684

Results: The X mean is: 7.431709; the Y mean is: 23.72684;

2. The code is as follows:

print(var(x))

[1] 2.035968

print(var(y))

[1] 32.57549

c<-cov(x,y)

print©

[1] 8.143872

co<-cor(x,y)

print(co)

[1] 1

Results: D(X)=2.035968; D(Y)=32.57549; Covariance: 8.143872; Correlation coefficient: 1;

3. The code is as follows:

y1=xexp(2x^0)

print(cor(x,y1))

[1] 1

y2=xexp(2x^1)

print(cor(x,y2))

[1] 0.6717004

y3=xexp(2x^2)

print(cor(x,y3))

[1] 0.2122434

Conclusion: From the data, it can be seen that as n continues to grow, the correlation between x and yi becomes smaller and smaller. This shows that the exponential distribution is related to the uniform distribution, and if X obeys the exponential distribution, the sufficient and necessary condition is that Y=1-e^λx obeys the uniform distribution. In addition, the larger the value of x, the weaker its correlation.