统计代写|随机过程代写stochastic process代考|The R script below simulates

statistics-lab™ 为您的留学生涯保驾护航 在代写随机过程stochastic process方面已经树立了自己的口碑, 保证靠谱, 高质且原创的统计Statistics代写服务。我们的专家在代写随机过程stochastic process代写方面经验极为丰富，各种代写随机过程stochastic process相关的作业也就用不着说。

• Statistical Inference 统计推断
• Statistical Computing 统计计算
• (Generalized) Linear Models 广义线性模型
• Statistical Machine Learning 统计机器学习
• Longitudinal Data Analysis 纵向数据分析
• Foundations of Data Science 数据科学基础

统计代写|随机过程代写stochastic process代考|The R script below simulates

EXERCISE 2.4. (a) The R script below simulates the trajectories and terminates them if the barrier is hit. Otherwise, trajectories continue for 1,000 steps. The total number of trajectories that hit the barrier is counted. We also record the number of steps (for part (b)) and the $y$-coordinate (for part (c)).

nhits<- 0

set.seed (50118)

defining walk as matrix

walk<- matrix (NA, nrow=1001, ncol=2)
nsteps<-c()
ycoord<- c()

defining random steps

Istep<- matrix $(c(1,0,-1,0,0,1,0,-1)$, nrow=4, ncol=2, byrow=TRUE)

simulating trajectories

for (j in 1:10000)
1
walk $[1,]<-c(0,0$, #setting initial value to the origin
for (i in 2:1001)
\&
walk $[i,]<-$, walk $[i-1,]+$, rstep $[\operatorname{sample}(1: 4, \operatorname{size}=1),$,
if $($ walk $[i, 1]==30) \quad$ {
nhits=nhits+1
break ?
1
nsteps [j]<- i
ycoord $[j]<-$ ifelse $(i==1001,99999$, walk $[i, 2])$
1
print (nhits)
1764
So, of the 10,000 trajectories, 1,764 hit the vertical barrier. Thus, the estimated probability to hit the barrier is $0.1764$.

(b) The average number of steps it takes a trajectory to hit the barrier, provided it did hit the barrier within the 1,000 steps, is estimated as
mean (nsteps [nsteps ! =1001])
$623.2053$
It took on average $623.2$ steps to hit the barrier for the $17.64 \%$ of the trajectories that terminated at the barrier.
(a) Estimate the expected value of the $y$-coordinate at the time when the random walk hits the barriet What should this value be from the theoretical point of view? Hint: deduce from a symmetry argument.
mean $($ ycoord $[$ ycoord $!=99999]))$
$0.1066364$
The estimated average $y$-coordinate for $17.64 \%$ of the trajectories that hit the barrier was $0.1066$. From the theoretical viewpoint, using the symmetry of the random walk, we can argue that the $y$ coordinate should be equal to 0 .

统计代写|随机过程代写stochastic process代考|By running the following script

EXERCISE 2.5. By running the following script, we simulate trajectories and calculate the number of those that hit the barrier. The plot is given below.
Nhits<- c()

specifying seed

set.seed $(96770)$

defining walk as matrix

walk<- matrix (NA, nrow=1001, ncol=2)

defining random steps

rstep<- matrix $(c(1,0,-1,0,0,1,0,-1)$, nrow=4, ncol=2, byrow=TRUE $)$

varying the barrier value

for (barrier in $1: 50$ ) \&
nhits<- 0
Hyimulating trajectordes
for (j in 1:100)
1
walk $[1,]<-c(0,0$, #setting initial value to the origin
for (i in 2:1001)
{
walk $[1,]<-\operatorname{walk}[i-1,]+\operatorname{rstep}[\operatorname{sample}(1: 4, \operatorname{size}=1),$,
if (walk[i,1]==barrier) |
nhits=nhits+1
break ?
)
1
Nhits [barrier] =nhits
1

print (Nhits)
$$\begin{array}{rrrrrrrrrrrrr} {[1]} & 93 & 94 & 93 & 94 & 87 & 85 & 72 & 66 & 66 & 66 & 61 & 61 \ {[13]} & 66 & 43 & 49 & 49 & 44 & 46 & 37 & 38 & 39 & 31 & 33 & 29 \ {[25]} & 30 & 28 & 19 & 24 & 17 & 18 & 23 & 13 & 22 & 12 & 8 & 9 \ {[37]} & 8 & 10 & 8 & 11 & 6 & 8 & 4 & 7 & 4 & 6 & 3 & 4 \ {[49]} & 4 & 1 & & & & & & & & & & \end{array}$$
plot $(1: 50$, Nhits/100, col=”blue”, xlab=”Position of barrier”, ylab=”Probability of hitting barrier”, panel.first=grid())

统计代写|随机过程代写stochastic process代考|Conditioning on the outcome

EXERCISE 2.7. (a) Conditioning on the outcome of the first step, we see that the probability $\boldsymbol{P}{i}$ solves the recurrence relation $\boldsymbol{P}{i}=p \boldsymbol{P}{i+1}+q \boldsymbol{P}{i-1}$ with the border constraints $\boldsymbol{P}{A}=0$ and $\boldsymbol{P}{B}=1$. Assuming first that $\frac{q}{p} \neq 1$, we look for the solution in the form $\boldsymbol{P}{i}=c\left(\frac{q}{p}\right)^{i}+d$ where $c$ and $d$ are some constants that can be found from the boundary conditions: $\boldsymbol{P}{A}=0=c\left(\frac{q}{p}\right)^{A}+d$ and $\boldsymbol{P}{B}=1=$ $c\left(\frac{q}{p}\right)^{B}+d$. From here, $c=-\frac{1}{\left(\frac{q}{p}\right)^{\Lambda}-\left(\frac{q}{p}\right)^{B}}$ and $d=\frac{\left(\frac{q}{p}\right)^{A}}{\left(\frac{q}{p}\right)^{A}-\left(\frac{q}{p}\right)^{B}}$, and thus, $P{i}=\frac{\left(\frac{q}{p}\right)^{A}-\left(\frac{q}{p}\right)^{i}}{\left(\frac{q}{p}\right)^{A}-\left(\frac{q}{p}\right)^{B}}$.
Now assume $\frac{q}{p}=1$. We look for the solution of the recurrence relation in the form $\boldsymbol{P}{\ell}=c i+d$. Again, from the boundary conditions, $\boldsymbol{P}{A}=0=c A+d$ and $\boldsymbol{P}{B}=1=c B+d$. Hence, $c=\frac{1}{B-A}$ and $d=-\frac{A}{B-A}$, leading to $\boldsymbol{P}{i}=\frac{i-A}{B-A}$.
(b) By conditioning on the first step, we see right away that the expectation satisfies the recurrence relation $\boldsymbol{E}{i}=p \boldsymbol{E}{i+1}+q \boldsymbol{E}{i-1}+1$ with the boundary conditions $E{A}=E_{B}=0$. Because of the additive constant term, this equation is referred to as a non-homogeneous relation and the general solution is sought in the form $\boldsymbol{E}{i}=c\left(\frac{q}{p}\right)^{i}+d+\frac{i}{q-p}$, if $\frac{q}{p} \neq 1$, and $\boldsymbol{E}{i}=c i+d-i^{2}$, if $\frac{q}{p}=1$. The constants $c$ and $d$ are found from the boundary conditions. In the former case, they satisfy $\boldsymbol{E}{A}=0=c\left(\frac{q}{p}\right)^{A}+d+\frac{A}{q-p}$ and $\boldsymbol{E}{B}=0=c\left(\frac{q}{p}\right)^{B}+d+\frac{B}{q-p}$. Whence,
$$c=\frac{B-A}{q-p} \cdot \frac{1}{\left(\frac{q}{p}\right)^{A}-\left(\frac{q}{p}\right)^{B}},$$
and
$$d=-\frac{B-A}{q-p} \cdot \frac{\left(\frac{q}{p}\right)^{B}}{\left(\frac{q}{p}\right)^{A}-\left(\frac{q}{p}\right)^{B}}-\frac{B}{q-p}$$
resulting in

$$\boldsymbol{E}{i}=\frac{B-A}{q-p} \cdot \frac{\left(\frac{q}{p}\right)^{i}-\left(\frac{q}{p}\right)^{B}}{\left(\frac{q}{p}\right)^{A}-\left(\frac{q}{p}\right)^{B}}-\frac{B-i}{q-p}$$ In the latter case, $c$ and $d$ solve $E{A}=0=c A+d-A^{2}$ and $E_{B}=0=c B+d-B^{2}$. From here, $c=A+B$ and $d=-A B$. Thus, $\boldsymbol{E}{i}=(A+B) i-A B-i^{2}=(B-i)(i-A)$. (c) We use the formulas derived above with $p=0.47, q=0.53, A=10, i=40$, and $B=80$. We obtain $$\boldsymbol{P}{40}=\frac{\left(\frac{0.53}{0.47}\right)^{10}-\left(\frac{0.53}{0.47}\right)^{40}}{\left(\frac{0.53}{0.47}\right)^{10}-\left(\frac{0.53}{0.47}\right)^{80}}=0.007962$$
and
$$\boldsymbol{E}_{40}=\frac{80-10}{0.53-0.47} \cdot \frac{\left(\frac{0.53}{0.47}\right)^{40}-\left(\frac{0.53}{0.47}\right)^{80}}{\left(\frac{0.53}{0.47}\right)^{10}-\left(\frac{0.53}{0.47}\right)^{80}}-\frac{80-40}{0.53-0.47}=490.7115$$
The probability of doubling the fortune in this rigged game is very small (about $0.008$ ), and the gambler will play, on average, about 491 games before he walks out of the casino.

统计代写|随机过程代写stochastic process代考|The R script below simulates

n命中<- 0

set.seed (50118)

将walk定义为矩阵

walk<- 矩阵 (NA, nrow=1001, ncol=2)
nsteps<-c()
ycoord<- c()

定义随机步骤

Istep<- 矩阵(C(1,0,−1,0,0,1,0,−1), nrow=4, ncol=2, byrow=TRUE)

模拟轨迹

1

for (i in 2:1001)
\&
walk[一世,]<−， 走[一世−1,]+, r 步[样本⁡(1:4,尺寸=1),,

nhits=nhits+1

1
nsteps [j]<- i
ycoord[j]<−如果别的(一世==1001,99999， 走[一世,2])
1
print (nhits)
1764

(b) 轨迹撞到障碍物的平均步数，假设它确实在 1,000 步内撞到障碍物，估计为

623.2053

(a) 估计预期值是- 随机游走击中 barriet 时的坐标 从理论的角度来看，这个值应该是多少？提示：从对称论证中推导出来。

0.1066364

统计代写|随机过程代写stochastic process代考|By running the following script

Nhits<-c()

将walk定义为矩阵

walk<- 矩阵（NA，nrow=1001，ncol=2）

定义随机步骤

rstep<- 矩阵(C(1,0,−1,0,0,1,0,−1), nrow=4, ncol=2, byrow=TRUE)

改变障碍值

nhits<- 0
Hyimulating 轨迹

1
walk[1,]<−C(0,0, #将初始值设置为原点
for (i in 2:1001)
{
walk[1,]<−走⁡[一世−1,]+rstep⁡[样本⁡(1:4,尺寸=1),,
if (walk[i,1]==barrier) |
nhits=nhits+1

)
1
Nhits [障碍] =nhits
1

[1]939493948785726666666161 [13]664349494446373839313329 [25]3028192417182313221289 [37]81081168474634 [49]41

统计代写|随机过程代写stochastic process代考|Conditioning on the outcome

(b) 通过以第一步为条件，我们立即看到期望满足递归关系和一世=p和一世+1+q和一世−1+1有边界条件和一种=和乙=0. 由于附加常数项，该方程被称为非齐次关系，并以形式寻求通解和一世=C(qp)一世+d+一世q−p， 如果qp≠1， 和和一世=C一世+d−一世2， 如果qp=1. 常数C和d由边界条件求得。在前一种情况下，它们满足和一种=0=C(qp)一种+d+一种q−p和和乙=0=C(qp)乙+d+乙q−p. 何处，
C=乙−一种q−p⋅1(qp)一种−(qp)乙,

d=−乙−一种q−p⋅(qp)乙(qp)一种−(qp)乙−乙q−p

有限元方法代写

tatistics-lab作为专业的留学生服务机构，多年来已为美国、英国、加拿大、澳洲等留学热门地的学生提供专业的学术服务，包括但不限于Essay代写，Assignment代写，Dissertation代写，Report代写，小组作业代写，Proposal代写，Paper代写，Presentation代写，计算机作业代写，论文修改和润色，网课代做，exam代考等等。写作范围涵盖高中，本科，研究生等海外留学全阶段，辐射金融，经济学，会计学，审计学，管理学等全球99%专业科目。写作团队既有专业英语母语作者，也有海外名校硕博留学生，每位写作老师都拥有过硬的语言能力，专业的学科背景和学术写作经验。我们承诺100%原创，100%专业，100%准时，100%满意。

MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。