Matematik simulation and monte carlo with applications in finance and mcmc phần 7 ppt

35 389 0
Matematik simulation and monte carlo with applications in finance and mcmc phần 7 ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Solutions 5 195 9.5 Solutions 5 1. (a) Using 5000 replications, each replication generating a primary and antithetic waiting time for five customers, the mean such time was 1.287 and the standard error was 0.00777. The estimated variance reduction ratio is approximately 2.5. (b) Using the same seed, the corresponding results were 5.4751, 0.00820, and 14. The v.r.r. is now better as W i is now more linear in A i and S i−1 than in (a). Why? 4. (b) (i) t =28386. 5. The conditional probability density function is f XX∈  a i−1 a i   x  =−N ln  x  on support  a i−1 a i  , since for equiprobable intervals, P  X ∈  a i−1 a i  = 1/N . For large N, there is little variation in f over  a i−1 a i  , except for i = 1, so a uniform envelope is appropriate. Therefore, for i ≥ 2, 1 generate X ∼ U  a i−1 a i  generate R ∼ U  0 1  if R< −ln X −ln  a i−1  deliver X else goto 1 For i = 1, we could continue to use inversion. For large n this will not degrade the performance much. 10. Let f denote the p.d.f. of points uniformly distributed over D. Since  ···  m  j=1 dx j = 1 m! it follows that f  x  1  x  m   = m!  x  1  x  m   ∈ D Therefore,  ···  D  m  j=1 m −j +1 2 x j  dx = 1 m! E f  m  j=1 m −j +1 2 x j   Points are sampled uniformly over D by sampling uniformly over 0 1 m and then sorting the coordinates so that 0 <x  1  < ··· <x  m  < 1. The Maple code below shows the numerical derivation of a 95 % confidence interval for the integral. Note that the naive approach of sampling points uniformly over 0 1 m and accepting only those that lie in D would be hopelessly inefficient. 196 Solutions > restart; > with(stats); [anova, describe, fit, importdata, random, statevalf, statplots, transform] > randomize(96341641); > n = 10000 m = 10; n = 10000 m = 10 > for i from 1 to n do; for j from 1 to m do; a[j]:=evalf(rand()/10ˆ12); end do; b:=[seq(a[j],j=1 m)]; c:=transform[statsort](b); d:=0; for j from 1 to m do; d = d +m −j+1 ^ 2∗cj; end do; end do: f:=[seq(e[i],i=1 n)]: g1:=describe[mean](f)/m!; g2:=describe[standarddeviation[1]](f)/m!; interval:=evalf([g1-1.96 ∗ g2/sqrt(n),g1+196 ∗ g2/sqrt(n)]); g1 := .00003042677684 g2 := .9879697859e-5 interval := [.00003023313476, .00003062041892] 9.6 Solutions 6 1. Put call parity gives c  t  +Ke −r  T−t  =p  t  +x  t  e −r f T−t . Using the result derived for the delta of the corresponding call option, p  t  x  t  = c  t  x  t  −e −r f T−t = e −r f T−t   d r f  −e −r f T−t =−e −r f T−t  1 −  d r f  =−e −r f T−t   −d r f  2. Use put call parity with r f = 0. This gives (a) p = £12086, (b) p = £18638, and (c) p = £26894. The seller of a put will initially hedge his or her position by having Solutions 6 197 a portfolio consisting of −1 put and  blocks of shares, where  =−  −d  (see Problem 1) and d =  r + 2 /2   T −t  +lnxt/K  / √ T −t. The number of shares shorted initially is (a) 328, (b) 440, and (c) 553. 3. (a) Let P  X  T   t x  t  denote the payoff for the bond holder at time T, given that the current FTSE is at x  t  . Then P  X  T   t x  t  = ⎧ ⎪ ⎪ ⎨ ⎪ ⎪ ⎩ 1 X  T  X  0  < 1 1 + 1 2  X  T  X  0  −1   1 ≤ X  T  X  0  < 16 1 +03 16 ≤ X  T  X  0   In a risk-neutral world, X  T  = x  t  exp   r −05 2   T −t  + √ T −tZ  where Z ∼ N  0 1  . Let Q  Z  t x  t  denote the payoff as a function of Z rather than of X  T  and let d 1 = ln  x  0  /x  t   −  r −05 2   T −t   √ T −t  d 2 = ln  16x  0  /x  t   −  r −05 2   T −t   √ T −t  Then Q  Z  t x  t  = ⎧ ⎪ ⎪ ⎨ ⎪ ⎪ ⎩ 1 Z<d 1  1 + 1 2  X  T  −X  0  X  0   d 1 ≤ Z<d 2  1 +03d 2 ≤ Z and so V  x  t  t  =e −r  T−t  ×  1 + 1 2  d 2 d 1  x  t  x  0  e  r−05 2   T−t  + √ T−tz −1    z  dz +03  −d 2   (b) The following Maple procedure computes this for given t and xt, where xt =x  t  is expressed in terms of x0. > capped_bond:=proc(xt,t) local r,sigma,T,b,d1,d2,P,price; r =004; sigma = 02; T = 4; b = xt/x0; d1 = ln1/b-r-05 ∗ sigmaˆ2 ∗ T-t/sqrtT-t/sigma; 198 Solutions d2 = ln16/b-r-05 ∗ sigmaˆ2 ∗ T-t/sqrtT-t/sigma; P = 05 ∗ b ∗ expr-05 ∗ sigmaˆ2 ∗ T-t +sigma ∗ sqrtT-t ∗ z-1 ∗ exp-05 ∗ zˆ2/sqrt2 ∗ Pi; price = exp-r ∗ T-t ∗ 1 +intP z = d1d2 +03 ∗ statevalf[cdf,normald](-d2)); print(”price at time”,t,”is £”,price); end proc; It is found that V  x  0   0  = £09392 and (c) that V  18x  0   2  = £11678. 4. (a) At time T portfolio A has the value K +V  x  T  T  = K +x  T  −K = x  T  , which is the same as the value of portfolio B. Therefore, the two portfolios must have identical values at any time t ∈  0T  otherwise a riskless profit could be made by investing in the cheaper portfolio. At time t, the cash in A has grown to Ke −rT e rt so the value of portfolio A is Ke −rT−t +V  x  t  t  while that of B is x  t  . Equating these two gives the desired result. (b) We have V/x  t  = 1, V/t = r  V  x  t  t  −x  t   , and  2 V/x  t  2 = 0; the result follows by substitution. (c) A portfolio that is a long one forward contract and a short one share will have the value at time t given by V  x  t  t  −x  t  =−Ke −rT−t . Since there is no uncertainty in −Ke −rT−t for all t ∈  0T  , the hedge is perfect. In practice the hedge involves, at time zero, selling short one share for x  0  . A forward contract is purchased for V  x  0   0  = x  0  −Ke −rT , leaving an amount of cash Ke −rT . This grows to K at time T, which is used at that time to meet the obligations on the forward contract and to the initial lender of the share. (d) The delivery price K is now such that V  x  0   0  =0. The contract at time zero has zero value. No money passes between A and B at that time. This is a standard forward contract. 5. At time zero, the writer of the option sets up a portfolio consisting of a −1 call option and   0  shares. The share purchase is financed by borrowing   0  X  0  . At time T this has grown to   0  X  0  e rT . At time T,ifX  T  >K, then a further 1 −  0  shares are purchased at a cost of  1 −  0   X  T  . Since the customer will exercise the option, the writer will sell the one share for K. The total cost at time T of writing and hedging the option in this case is   0  X  0  e rT +  1 −  0   X  T  −K Otherwise, if X  T  ≤ K at time T, the writer will sell the existing   0  shares, obtaining   0  X  T  . The total cost of writing and hedging the option in this case is   0  X  0  e rT −  0  X  T   Bringing these two results together, the total cost is   0  X  0  e rT −  0  X  T  +  X  T  −K  +  Solutions 6 199 The present value of this is C =   0  X  0  −  0  X  T  e −rT +e −rT  X  T  −K  +  Therefore, E  C  −c =E    0  X  0  −  0  X  T  e −rT +e −rT  X  T  −K  +  −c =  0  X  0  −E    0  X  T  e −rT  +e −rT  X  0    d   e T −K  d  − √ T  −e −rT  X  0    d  e rT −K  d − √ T  =  0  X  0  −  0  X  0  e  −r  T +e −rT X  0    d   e T −X  0    d  +Ke −rT    d − √ T  −  d  − √ T  =X  0  e  −r  T    d   −  d   +Ke −rT    d − √ T  −  d  − √ T  and this is plotted in Figure 9.4. Notice that when  =r, there is no difference between the expected cost of writing and hedging the option in this way and the Black–Scholes price. 5 10 15 20 25 30 mean penalty cost –0.2 –0.1 0.1 0.2 0.3 mu Figure 9.4 Plot of EC −c against , problem 6.5 200 Solutions 6. From Equation (6.30), c g = e −rT E N  01   X 0 e r− 2 /2n+1/2h+ √ h/n  n i=1 n−i+1Z j −K  + Put Z =  n i=1 n −i+1Z j   n i=1 n −i+1 2 =  n i=1 n −i+1Z j  n  n +1  2n +1  /6 =  n i=1 n −i+1Z j √ a ∼ N  0 1   Then c g = e −rT E N  01   X 0 e r− 2 /2n+1/2h+ √ ahZ/n −K  + and lim n→ c g = e −rT E N  01   X 0 e r− 2 /2T/2+ √ TZ/ √ 3 −K  + = e −rT E N  01   X 0 e r−q− 2 /2T +  √ TZ −K  + where   = / √ 3 and r −q − 1 2  2 = 1 2  r − 1 2  2   that is q = 1 2 r +  2 12  and the result follows from Equation (6.20). 9. (a) We have that c = e −rT E Y∼N  0I   1 n n  j=1 x  0  e  r− 2 /2  jh+ √ h  j i=1 Y i  −K  + Making the suggested substitutions, c = e −rT E Y∼N  0I   n  j=1 1 n x j e  r− 2 j /2  T+ j √ TZ j  −K  + Solutions 6 201 where Z j =  j i=1 Y i / √ j ∼ N  0 1  for j = 1n. This is clearly the price of a basket option with quantities 1/n of each asset, where the correlation on the returns between assets j and m  ≥ j  is Cov  Z j Z m  = Cov   j i=1 Y i √ j   m i=1 Y i √ m  = 1 √ jm j  i=1 Var  Y i  =  j m (b) The following Maple execution group makes the necessary substitutions and creates the correlation matrix of returns between the 16 equivalent assets. > n: = 16 r: = 005 x: =Vectorn sigma: = Vectorn q: = Vectorn; rho: = Matrixn T: =1 t: = 0 m: =20; npath: = 400 p: = 100 K: =50 upper: = 200; T: = 1 sig: =03 x0: =50; h: = evalfT/n; f: = i j- > if i < j then evalfsqrt i/j else evalfsqrtj/i end if: rho: = Matrixn f; for j from 1 to n do; xj: = x0 ∗ expr ∗ j ∗ h −T; qj: = evalf1/n; sigmaj: = sig ∗ sqrtj ∗ h/T; end do; spot:=Transpose(x).q; From the resulting 100 replications, using basketimppoststrat seed = 9624651, each consisting of 400 payoffs over 20 strata, a price of 4.1722 with a standard error of 0.0014 was obtained. This compares with a value of 4.1708 and standard error of 0.00037 using 100 replications, each consisting of 2500 replications over 100 strata, as given in Table 6.2. Bearing in mind the different sample sizes and the sampling error, there is little to choose between the two approaches. 10. (a) Suppose  Y = 0. In the usual notation, an Euler approximation scheme is (in a risk-neutral world) X  T  ≈ x 0 e  n j=1  r− 2 j /2  h+ j √ h  √ 1− 2 Z j +W j  where  j = e Y j  Y j = Y j−1 e −h +m  1 −e −h  + √ 1 −e −2h W j for j =1n, with Y 0 =ln    0   .  W j  and  Z j  are independent sequences of N  0 1  random variables. 202 Solutions (b) (i) Antithetics can be implemented with ease at little extra cost, but the improvement may be unimpressive in many cases. (ii) Stratification may be promising for certain parameter values. The distribution of Y n given Y 0 is normal, so post-stratified sampling on Y n may be of some value for slow mean reverting processes. (iii) However, the method likely to be most successful is to note that conditional on W 1 W n  1  n , X n = X 0 e  n j=1   r− 2 j /2  h+ j √ h  √ 1− 2 Z j +W j   Put Z =  n j=1  j √ hZ j /  n j=1  2 j h 1/2 ∼ N  0 1  . Then X n = X 0 e  √ h  n j=1  j W j e  r− 2 /2  T+  T  1− 2  Z where  2 = 1/n  n j=1  2 j . Put  2 =  2  1 − 2  and S 0 = X 0 exp   √ h  n j=1  j W j  . Then X n = S 0 e  r− 2 /2n  n j=1  2 j − 2 /2  T+ √ TZ Let BS  S 0 sTKrq  denote the price at time zero of a European call with strike price K and exercise time T , on an underlying asset having an initial price S 0 which earns interest continuously at rate q with constant volatility s, and where the risk-free interest rate is r. Then  c = BS  X 0 exp   √ h n  j=1  j W j  TKr 1 2  2  2  This is an example of conditional Monte Carlo. 9.7 Solutions 7 1. (c) Each state variable, X  t  t ≥ 0, is a mixture of discrete and continuous, since there is a positive probability that none has been consumed in  0t  . The time variable is continuous. The system is a continuous event system during periods of consumption and is trivially a discrete state continuous time system during periods of abstinence. 2. (b) The ith event is at T  i  = 1/ ln  1 +  i  e −  where    i   follow a simple Poisson process of rate one. Stop at event number max  i  i  <1/e   e t 0 −1  . 3. It is probably easiest and quite efficient to use rejection of points falling in the rectangle  x y  x∈  −a a  y∈  −b b   , but not within the ellipse. Solutions 7 203 7. To obtain the theoretical result, let m i denote the mean time to absorption given the current state is i. Then m i =1 +  4 j=i p ij m j for i = 14. The expected life of the equipment is m 1 . 8. Since N  t  + K  t  + D  t  is a constant for all t ≥ 0 the state is uniquely represented by any two state variables, say  N  t  K  t  . The ‘leaving rate’ for state  n k  is  = nkp + n 2 + k 1 and so, given that  N  t  K  t  =  n k  , the next event is at time t −  −1 ln R, where R ∼ U  0 1  , and the state immediately after that event will be either  n −1k+1  or  n −1k  or  n k −1  with probabilities nkp/ n 2 / k 1 / respectively. Simulate realizations of the epidemic by setting  N  0  K  0  =  N −1 1  say. 12. (a) Given that there is an accident in  t t +t  , the conditional distribution of R, the distance of occurrence from the hospital, is given by P  R ≤ r  R ≤ 5  =  r 5  2 Using inversion of this cumulative distribution function gives  r/5  2 = U or r = 5 √ U,sox = 2  5 √ U/v  . (b) This is a five server (ambulance) queueing system with waiting customers (patients) forming one queue. Bound state changes are customer arrivals (emergencies) and customer departures (patients deposited at the hospital). Conditional state changes are starts of service (ambulances despatched to patients). For each of the five ambulances it is necessary to store (i) the time at which it next deposits a patient at the hospital and (ii) the time at which the patient incurred the emergency. Suppose these are called TD  j  and TA  j  respectively for j = 15. Let b = number of busy servers, q = number of patients waiting for an ambulance, A = time of next emergency, clock = present time, and simtim = duration of simulation. Let A  j  = time of arrival of the patient who is currently jth in the queue for an ambulance. Then, assuming ambulances are despatched to emergencies on a ‘first come, first served’ protocol, the core part of a simulation might be based around the following algorithm: While clock < simtim do clock = min  A TD  1  TD  5   If event is arrival  clock = A  then q= q +1 A= clock +interarrivaltime A  q  = clock end if If event is departure then identify j the server involved print clock −TAj TA  j  = 0 (arbitrary value) 204 Solutions TD  j  = b= b −1 end do If q>0 and b<5 then Identify j, a free server TD  j  = clock +service duration TA  j  = A  1  A  1  = sort  A  k  k= 1q  q= q −1 b= b +1 end if End do 13. The bound state changes are machine breakdowns, completion of machine repairs, and completion of machine tests. Conditional state changes are repair starts and testing starts. Let the time of the next state change for machine j be T  j  . Let the state of machine j be S  j  = 1 2 3 4 5 according to whether it is working, in the repair queue, being repaired, in the testing queue, or being tested respectively. Let nw,nr, and nt denote the number of machines working, the number of repairmen who are free, and the number of testers who are free respectively. Let qr and qt denote the number of machines in the repair queue and testing queue respectively. Let clock and clockprev denote the current simulation time and time at the previous event respectively. If working periods happen to be exponentially distributed, then regeneration points would exist at those events where the number of working machines changes from m −1tom. Otherwise, regenerative analysis cannot be used, since the only regenerative points (assuming steady state behaviour) are those instants at which all machines are returned simultaneously to the working state – an impossibility with continuous random variables. Therefore, a proper analysis should plot nw against clock and identify a burn-in period, tb. Then a point estimate of the long-run average utilization will be  1/  m  simtim −tb     simtim tb nw  t  dt. A confidence interval may be obtained by replicating a large number of realizations over identical values of simtim and tb, preferably starting in different states. 14. (a) Bound events are customer arrivals, customer departures from window A, and customer departures from window B. Conditional events are the start of service at window A, the start of service at window B, a queue-hop from A to B, and a queue-hop from B to A. (c) Regeneration points are when one server is idle and the other one becomes idle. If the traffic intensity is not too close to 1, these will occur frequently enough to allow a regenerative analysis. 15. This is similar to Problem 13, but here the individual waiting times need to be recorded. [...]... envelopeaccep:=proc(h::procedure,r::procedure,x1,x2,xinit) 6 local u,K,acc; 6 6 u:=NLPSolve(h(x)/r(x), 6 6 x=x1 x2,initialpoint={x=xinit},maximize); 6 6 K:=op(1,u); 6 6 print("envelope is",K*r(x)); 6 4 acc:=int(h(x),x=x1 x2)/int(r(x),x=x1 x2)/K; end proc: 2 4 Now the acceptance probability will be found when generating from a generalized inverse Gaussian distribution having a p.d.f proportional to Simulation and Monte Carlo: With applications in finance. ..  pffiffiffi y  Y  cos pffiffiffi dy ¼ Ef cos pffiffiffi     2 2  =2Þ  where f is Nð0; 1Þ 2 6 > restart ;with( stats); 4 [anova, describe, fit, importdata, random, statevalf, statplots, transform] 2 6 > randomize(135);n:=1000; 4 135 n:=1000 Simulation and Monte Carlo: With applications in finance and MCMC Ó 20 07 John Wiley & Sons, Ltd J S Dagpunar 210 Appendices 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6... length to increase progressively, since the arrival rate exceeds the service rate Appendix 2: Random number generators " In addition to the in- built Maple generator ‘rand’, the following generators described in Chapter 2 can also be used 2 6 > r1:= proc() global seed; 6 seed:=(90618 574 9 *seed+1) mod 2^31; 6 4 evalf(seed/2^31); end proc: 2 6 > r2:= proc() global seed; 6 seed:=(286293355 577 794 175 7 *seed+1)... specified positive constants The aim is to investigate the distribution of time until the beetle arrives in the treacle pot starting from the point ðx0 ; y0 Þ on the cardboard (a) Write a procedure that simulates n independent times between starting at the point ðx0 ; y0 Þ and landing in the treacle The function stats [random,normald](1) creates a random standard normal deviate 215 216 6 6 6 6 6 6 6... estimate the mean waiting time under stationarity 2 6 6 6 6 6 6 6 6 6 6 6 6 6 4 > waittimes:=seq(op(2,v[i]),i=1 1000): mean_waiting_time=evalf(describe[mean] ([waittimes])); standard_deviation_of_waiting_time=evalf (describe[standard deviation[1]]([waittimes])); mean_waiting_time = 0.9 375 110082 standard_deviation_of_waiting_time = 1. 478 7 176 53 The theoretical stationary mean waiting time is 1 The difference... reduction in variance Problem 1.5 An intoxicated beetle moves over a cardboard unit circle x2 þ y2 < 1 The ðx; yÞ plane is horizontal and the cardboard is suspended above a wide openffiffiffiffi of p jar treacle In pffiffiffiffi time interval ½t; t þ tÞ it moves by amounts x ¼ Z1 1 t and the y ¼ Z2 2 t along the x and y axes where Z1 and Z2 are independent standard normal random variables and 1 and 2 are... replacement is better when cp =cf < 6 37= 2500 Problem 1.4 2 Two points A and B are selected randomly in the unit square ½0; 1Š2 Let D 6 6 denote the distance between them Using Monte Carlo: 6 6 6 (a) Estimate EðDÞ and V arðDÞ 6 6 (b) Plot an empirical distribution function for D 6 6 4 (c) Suggest a more efficient method for estimating P ðD > 1:4Þ, bearing in mind that this probability is very small... 1.1 Use a Monte Carlo method, based upon 1000R random standard normal 1 deviates, to find a 95 % confidence interval for À1 expðÀx2 Þjcos xjdx Use the Maple with( stats)’ command to load the stats package The function stats[random,normald](1) will generate a random standard normal deviate 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 4 Solution 2 6 6 6 6 6 6 4 pffiffiffi Let x ¼ y= 2 Then the integral becomes... the MCMC independence sampler shows that the acceptance rate, although poor, is not quite so low (approximately 7. 5 %) In the independence sampler the probability of acceptance of a candidate point c c is min 1 L c c /L where is the current point This is always greater than L c c /Lmax , the acceptance probability using envelope rejection Offset against this is the fact that envelope rejection gives independent... variable in each of these Therefore, 6 6 any procedures calling these generators will likewise have to declare ‘seed’ as 6 6 a global variable The procedure ‘expon’ below generates a variate from the 6 6 density fðxÞ ¼ eÀx on support ½0; 1Þ It calls the random number generator 4 ‘schrage’ The final execution group sets an (initial) seed and calls ‘expon’ three times Simulation and Monte Carlo: With applications . randomize(135);n:=1000; 135 n:=1000 2 6 4 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 4 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 4 Simulation and Monte Carlo: With applications in finance and MCMC J. S. Dagpunar Ó 20 07 John Wiley & Sons, Ltd > u:=evalf(sqrt(2)):v:=evalf(sqrt(Pi)): for. of 4. 170 8 and standard error of 0.000 37 using 100 replications, each consisting of 2500 replications over 100 strata, as given in Table 6.2. Bearing in mind the different sample sizes and the. 5 1. (a) Using 5000 replications, each replication generating a primary and antithetic waiting time for five customers, the mean such time was 1.2 87 and the standard error was 0.0 077 7. The estimated

Ngày đăng: 09/08/2014, 16:21

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan