Original link:tecdat.cn/?p=17303 

Original source:Tuo End number according to the tribe public number

 

In this paper, we discuss an optimal algorithm for combining Poisson process with Wiener process. In fact, in order to generate poisson processes, we are always used to simulating the duration between jumps. We use the uniformity of jumps over a given time interval, which depends on the number of jumps.

First, we can generate a Wiener process that might have a drift, and then, next to that, we can generate exponential laws (which would correspond to the time between jumps), and we can also generate jump magnitudes. Here we are

either. We start by noticing

Where the increments are Gaussian (mean and variance) and are independent of each other. As for the duration between jumps, they are independent of the law of averages. This is the code,

n=1000
h=1/n
lambda=5
set.seed(2)
W=c(0,cumsum(rnorm(n,sd=sqrt(h))))
W=rexp(100,lambda)
N=sum(cumsum(W)<1)
T=cumsum(W[1:N])
X=-rexp(N)
Copy the code

The problem is that for wiener processes, we have to discretize, and for composite Poisson processes, we cannot discretize. However, they have the same time frame. The first approach is to set up the Trunc function


W[trunc(n*t)+1]+sum(X[T<=t])+lambda*t
Copy the code

And visualize

L=Vectorize(Lt

plot(u,L(u),type="l
Copy the code

 

 

Another possibility is to use the uniformity of poisson processes that I mentioned in the introduction. Because the Poisson process satisfies one property: if it is the date of the i-th jump, it is conditional based on the following facts:, the variable

Order statistics corresponding toThe independent variables are uniformly distributed

This property can be found in Wolff (1982). We start with a (single) jump,

 

So we find a uniform distribution function. Then, we iterate 2 hops, 3 hops, etc.

The R translation of this idea is simple

N=rpois(1,lambda)
Copy the code

Then, one strategy is to discretize Poisson processes with the same time step as Wiener processes,

indice=trunc(T*n
processus=W+cumsum(saut)+lambda*u
Copy the code

We found the same trajectory as before

 

By doing this, we cannot make two jumps in the same time interval. The poisson process is characterized by

 

As a result, it is rare to have two jumps at the same time, especially if the time step is small. If we generate thousands of tracks, the probability of a single problem is negligible.

One idea is to have a discrete uniform distribution,

T=c(0,sort(sample((1:(n-1)/n),size=N,replace=FALSE)))
Copy the code

To avoid two jumps at the same time.

To that end, we can do some tests. For example, generate simulations that have a hundred jumps (so the duration between jumps is a hundred) and then perform exponential law tests.

VT=0
for(ns in 1:20){
N=rpois(1
Copy the code

We did 20 loops here

lambda=5
Copy the code

I’d like to make a hundred observations to test it out. And then, we can do exponential fit tests,

ks.test(VT[-1],"pexp",lambda)$p.value
Copy the code

By changing the time step (or the fine fraction of the time interval) if we repeat it many times, we will generally reject it if the time step is large (lower left), as is the case with the exponential law. But very quickly, this is a hypothesis that doesn’t work,

 

 

We have two good algorithms for generating Levy processes.


Most welcome insight

1.R language Poisson regression model analysis case

2. Numerical simulation in R language: Poisson regression model was simulated

3. Poisson regression analysis for R language

4.R language simulation and dynamic visualization of Buffon needle drop (Buffon needle drop) experiment

5. Use R language to simulate the mixed queuing random service queuing system

6. VaR comparison of GARCH (1,1), MA and historical simulation method

7.R language to do geometric Brownian motion simulation of complex financial products

8. Numerical simulation in R language: Poisson regression model is simulated

9. Pricing of reinsurance contracts under catastrophe risk under R language: Generalized linear Models and Pareto distributions