okay great let's continue where we left off in our previous video we obtained the
drift and standard deviation values we will need for the calculations of
daily returns the type function allows us to check their type and see it as pandas series
to proceed with our task we should convert these values into numpy arrays you already
know that num pies array method can do this for us
however let me demonstrate how typing dot values after a panda's
object beat a series or a data frame can transfer the object into a numpy array
you see we obtain the same output for the drift as we did with numpy dot array then
STD values provides an analogical output and allows us to obtain the standard deviation
great the second component of the Brownian motion is a random variable Z a number corresponding to
the distance between the mean and the events expressed as the number of standard deviations
Syfy's norm dot PPF allows us to obtain this result if an event has a 95% chance of occurring
the distance between this event and the mean will be approximately one point six
five standard deviations okay this is how it works to complete the second component we will
need to randomize the well-known numpy rand function can help us do that easily if we want
to create a multi-dimensional array we will need to insert two arguments so I'll type ten and two
here you go we obtained a ten by two matrix we will include
this random element within the PPF distribution to obtain the distance
from the mean corresponding to each of these randomly generated probabilities
the first number from the first row corresponds to the first probability from the first row of
the X matrix the second element to the second probability as shown in the X matrix and so on
great the whole expression corresponding to Z will be of the type norm PPF open
parenthesis numpy random R and open another parenthesis 10 and to close all parentheses
the newly created array used the probabilities generated by the ran and converted them into
distances from the mean zero as measured by the number of standard deviations this expression
will create the value of Z as defined in our formula cool so once we have built these tools and
calculated all necessary variables we are ready to calculate daily returns all the infrastructure
is in place okay so first I would like to specify the time intervals we will use will
be 1000 because we are interested in forecasting the stock price for the upcoming 1000 days then
two iterations I will attribute the value of 10 which means I will ask the computer to produce
10 series of future stock price predictions okay the variable daily returns will show us what will
equal e to the power of R we discussed this in the theoretical lesson remember we will need numpy x'
exp function which means we are calculating Euler's number e raised to the power of the
expression written between the parentheses in the parenthesis we will have the value of the
drift in the product of the standard deviation and the random component created with the help of the
norm module its percentage value is generated with numpy strand function using time intervals
and iterations specifying the dimensions of the array filled with values from 0 to 1
great so the formula we used in the previous cell would allow us to obtain a 1000 by 1000
with daily return values 10 sets of 1000 random future stock prices great we are a single step
away from completing this exercise we'll do that in our next lecture thanks for watching