Back to Course

Monte Carlo Methods in Finance Engineering

0% Complete
0/0 Steps
  1. Course Introduction

    Introduction
    2 Topics
    |
    1 Quiz
  2. Lesson 1. Linear Congruental Generator
    2 Topics
    |
    1 Quiz
  3. Lesson 2. Normally Distributed Random Variables and Vectors Generation
    2 Topics
    |
    1 Quiz
  4. Lesson 3. Integral Estimation.
    2 Topics
    |
    1 Quiz
  5. Lesson 4. Expected Present Value
    1 Quiz
  6. Lesson 5. Brownian motion. Geometric Brownian motion
    2 Topics
    |
    1 Quiz
  7. Lesson 6. GBM. Path-Dependent Options
    1 Topic
  8. Lesson 7. The effectiveness of simulation evaluation
    2 Topics
    |
    1 Quiz
  9. Lesson 8. Variance reduction methods
    3 Topics
    |
    1 Quiz
  10. Lesson 9. Introduction to RTU High Performance Computing (HPC) Environment
Lesson Progress
0% Complete

Run the code with the different parameters

#1.uzdevums
a = 16807
c = 0
m = (2**31) - 1


def lcg():
    seed = 1
    for i in range(500):
        rd = (a * seed + c) % m
        seed = rd
        u = rd/m
        print(u)
lcg()

#____________________________________________________________________

#2.uzdevums
import math
a = 16807
c = 0
m = (2**31) - 1


def lcg():
    seed = 1
    for i in range(500):
        rd = (a * seed + c) % m
        seed = rd
        u = rd/m
        x = -1*math.log(u)
        print(x)
lcg()



#_____________________________________________________________________
#3.uzdevums
import math
import random
a = 16807
c = 0
m = (2**31) - 1


def lcg():
    seed = 1
    i = 0
    while i < 500:
            rd = (a * seed + c) % m
            seed = rd
            u1 = rd/m
            rd = (a * seed + c) % m
            seed = rd
            u2 = rd/m
            rd = (a * seed + c) % m
            seed = rd
            u3 = rd/m
            u = -1*math.log(u1)
            if u2 <= math.exp(-0.5*(u-1)**2):
                if u3 <= 0.5:
                    u = -1*u
                print(u)
                i += 1
lcg()