QMT634: Some Techniques for Generating Random variates
Author
Mohd Ramdan Harun
Last Updated
9 лет назад
License
Creative Commons CC BY 4.0
Abstract
QMT634: Some Techniques for Generating Random variates
QMT634: Some Techniques for Generating Random variates
% Copyright 2004 by Till Tantau <tantau@users.sourceforge.net>.
%
% In principle, this file can be redistributed and/or modified under
% the terms of the GNU Public License, version 2.
%
% However, this file is supposed to be a template to be modified
% for your own needs. For this reason, if you use this file as a
% template and not specifically distribute it as part of a another
% package/program, I grant the extra permission to freely copy and
% modify this file as you see fit and even to delete this copyright
% notice.
\documentclass{beamer}
% Replace the \documentclass declaration above
% with the following two lines to typeset your
% lecture notes as a handout:
%\documentclass{article}
%\usepackage{beamerarticle}
% There are many different themes available for Beamer. A comprehensive
% list with examples is given here:
% http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
% You can uncomment the themes below if you would like to use a different
% one:
\usetheme{AnnArbor}
%\usetheme{Antibes}
%\usetheme{Bergen}
%\usetheme{Berkeley}
%\usetheme{Berlin}
%\usetheme{Boadilla}
%\usetheme{boxes}
%\usetheme{CambridgeUS}
%\usetheme{Copenhagen}
%\usetheme{Darmstadt}
%\usetheme{default}
%\usetheme{Frankfurt}
%\usetheme{Goettingen}%kanan
%\usetheme{Hannover} % sebelah kiri
%\usetheme{Ilmenau}
%\usetheme{JuanLesPins}
%\usetheme{Luebeck}
%\usetheme{Madrid}
%\usetheme{Malmoe}
%\usetheme{Marburg}
%\usetheme{Montpellier}
%\usetheme{PaloAlto}
%\usetheme{Pittsburgh}
%\usetheme{Rochester}
%\usetheme{Singapore}
%\usetheme{Szeged}
%\usetheme{Warsaw}
\usepackage{amsbsy}
\usepackage{amstext}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{shadow}% kotak shadow
%\usepackage{chaptengah}
\usepackage{curves}
\usepackage{graphicx}
\usepackage{color}%masukan colorbegi
\usepackage{makeidx}
\makeindex
\usepackage{natbib}
\title{Some Techniques for Generating Random variates}
% A subtitle is optional and this may be deleted
\subtitle{2.5 Saila}
\author{Dr.~J\inst{1} \&\and Maziah.~Mahmud\inst{2}}
% - Give the names in the same order as the appear in the paper.
% - Use the \inst{?} command only if the authors have different
% affiliation.
\institute[Universities of Technology MARA] % (optional, but mostly needed)
{
\inst{1}%
Department of Mathematics\\
University of Technology MARA Kelantan, KB Campus
\and
\inst{2}%
Department of Mathematics\\
University of Technology MARA Kelantan, Machang campus}
% - Use the \inst command only if there are several affiliations.
% - Keep it simple, no one is interested in your street address.
\date{QMT634, 2016}
% - Either use conference name or its abbreviation.
% - Not really informative to the audience, more for people (including
% yourself) who are reading the slides online
\subject{QMT634}
% This is only inserted into the PDF information catalog. Can be left
% out.
% If you have a file called "university-logo-filename.xxx", where xxx
% is a graphic format that can be processed by latex or pdflatex,
% resp., then you can add a logo as follows:
% \pgfdeclareimage[height=0.5cm]{university-logo}{university-logo-filename}
% \logo{\pgfuseimage{university-logo}}
% Delete this, if you do not want the table of contents to pop up at
% the beginning of each subsection:
\AtBeginSubsection[]
{
\begin{frame}<beamer>{Outline}
\tableofcontents[currentsection,currentsubsection]
\end{frame}
}
% Let's get started
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}{Outline}
\tableofcontents
% You might wish to add the option [pausesections]
\end{frame}
% Section and subsections will appear in the presentation overview
% and table of contents.
\section{Some technique for generating random variates}
\subsection{Distribution}
\begin{frame}{Some technique for generating random variates}{2.5}
% \begin{itemize}
%\item {
%My first point.
% }
% \item {
% My second point.
%}
%\end{itemize}
Here we present useful techniques for generating random variates from a few relatively simple distribution.\\
\begin{tabular}{llll}
\textcolor{blue}{Distribution}&\textcolor{blue}{Parameters}&\textcolor{blue}{Formula}\\
&&\textcolor{blue}{Command}\\
&&\textcolor{blue}{in Excel}\\
\hline
Bernoulli&$p$&$X=\begin{cases}1&\text{if}\,\, U\le p\\0& \text{if}\,\, U>p \end{cases}$&\\
Uniform&$a<b$&$X=a+(b-a)U$\\
&&X=a+(b-a)*RAND()\\
\hline
Triangular&0,$\frac{1}{2}$,1&$X=\frac{1}{2}(U_1+U_2)$\\
&&$X=\frac{1}{2}*(RAND()$\\
&&$+RAND())$\\
\hline
Symmetric&$a<b$&${\small X=a+\frac{(b-a)}{2}(U_1+U_2) }$\\
triangular&&=$a+\frac{(b-a)}{2}*(RAND()+RAND())$
\end{tabular}
\end{frame}
%--------------
\begin{frame}{Cont..}
%\begin{exampleblock}{Distribution}
\begin{tabular}{lll}
Distribution&Parameters&Formula\\
&&(in Excel)\\
\hline
Right&$a<c$&$X=a+(c-a)\sqrt{U}$\\
triangular&&$X=a+(c-a)*\sqrt{RAND()}$\\
\hline
Approximately&0,1&$X=U_1+U_2$\\
normal&&$+\cdots+U_{12}-6$\\
\hline
Approximately&$X=\mu,\sigma$&$\mu+\sigma(U_1+U_2$\\
normal&&$+\cdots+U_{12}-6)$\\
\hline
Exponential&$\mu$&$X=-\mu\,\ln\,(U)$\\
&&$X=-\mu*LN(RAND())$\\
\hline
Discrete&$k,k+1,\ldots,k+m$&$X=k$\\
uniform&&$+int[(m+1)U]$\\
\hline
\end{tabular}
%\end{exampleblock}
\end{frame}
%----------------
%\subsection{Bernoulli Random variate}
\begin{frame}{Bernoulli Random variate}
The probability density of Bernoulli distribution is given by
\begin{equation}
f(x)=p^x(1-p)^{1-x}\,\,x=0,1
\end{equation}
\begin{itemize}
%\item \begin{figure}
%\centering
%\subfloat[]{\label{fig:c}}{\includegraphics[width=0.45\textwidth]{dinosaure_007.gif}}
%\end{figure}
\item $X$ has the value 1 with probability $p$ and value 0 with probability $1-p$.
\end{itemize}
\end{frame}
%----------------
\begin{frame}{Uniform Random Variates}
\begin{block}{}
\begin{itemize}
\item Pdf of $x$, $f(x)=\frac{1}{b-a},\,\,\,b>a$
\item A uniformly distributed random variate between $a$b and $b$, where $b>a$ can be computed from $X=a+(b-1)U$.
\item Use Excel $X=a+(b-a)RAND()$.
\item Thus, a uniformly distributed random variate between 0 and 10.0 is given by $X=10.0 u$.
\item a uniformly distributed random variate between 20.0 and 100.0 is given by $X=20.0+80.0 U$.
\end{itemize}
\end{block}
\end{frame}
%-------------
%----------------
\section{Triangular Random Variates}
\begin{frame}{Triangular Random Variates}
\begin{exampleblock}{}
\begin{itemize}
\item If $U_1$ and $U_2$ are uniformly distributed between 0.0 and 1.0, then $\frac{U_1+U_2}{2}$ has a symmetric triangular distribution between 0 and 1.0.
\item If we want a \textcolor{blue}{random variate}, $x$ to have a \textcolor{blue}{symmetric triangular distribution} random variate between $a$ and $B$, $X$ can be computed from
\begin{equation}
X=a+(b-a)(U_1+U_2)
\end{equation}
\item To generate variates from a \textcolor{blue}{nonsymmetric triangular distribution} between $a$ and $c$, where the most likely value is $c$. $X$ can be computed from
\begin{equation}
X=a+(c-a)\sqrt{U}
\end{equation}
\end{itemize}
\end{exampleblock}
\end{frame}
%-------------------
\section{Evaluating Decision}
\begin{frame}{Evaluating Decision:\\ A one-period Inventory Model}
\begin{block}{}
\begin{itemize}
\item The \textcolor{blue}{ultimate purpose} of every model is to predict the likely effects of alternative decision.
\item Example: Recall that in chapter 1 (Seila). Suppose we are \textcolor{blue}{responsible } for deciding how many canister to order for one game. One canister can serve 100 drinks. Let the \textcolor{blue}{demand} $D$ has an \textcolor{blue}{exponential distribution} with mean 5.0. The mean of $D$ is expressed in canister, or hundreds of drinks. Let $s$ represent the number of canisters of soft drink that we order. Because $D$ is a random variable, we cannot, for a given value of $s$, predict whether $D$ will be larger or smaller than $s$. If $D$ is larger than $s$, then we will \textcolor{blue}{run out}, and $D-s$ will be the amount of demand were \textcolor{blue}{unable to fill}.
\end{itemize}
\end{block}
\end{frame}
%-----------------
\begin{frame}{Cont..}
\begin{block}{}
Suppose that each unit (100 drinks) of \textcolor{red}{unmet demand} cost us \$40. (We can consider this the cost associated with customer dissatisfaction an unrealized potential profit).Thus the cost associated with \textcolor{blue}{ordering} $s$ canisters of soft drink, the $D$ is greater than $s$, is $40.0(D-s)$. Suppose we order too much soft drink so that $D$ is \textcolor{blue}{smaller} than $s$. In this case we will have $s-D$ canisters of soft drink \textcolor{blue}{left over}. Suppose that the \textcolor{blue}{cost per unit of excess} soft drink is \$10. (This is the cost associated with returning the soft drink to the bottler or otherwise disposing of it). Thus, the \textcolor{blue}{cost associated with ordering} $s$ canister, when $D$ is less than $s$ is $10.0(s-D)$. We want to determine the value of $s$ that minimizes the \textcolor{blue}{expected cost}.
\end{block}
\end{frame}
%-------------------
\subsection{Optimal Order Quantity Using Simulation}
\begin{frame}{Optimal Order Quantity Using Simulation}
\begin{exampleblock}{}
To solve this problem
\begin{itemize}
\item We first \textcolor{blue}{choose a value of $s$}, then set up an experiment in which the value of $D$ is generated from an \textcolor{blue}{exponential distribution with mean 5}.
\item Finally the \textcolor{blue}{cost} associated with this particular value of $s$ and $D$ is computed.
\item This experiment is \textcolor{blue}{replicated independently} $n$ times, producing $n$ observations of the \textcolor{blue}{cost}.
\item A \textcolor{blue}{confidence interval for mean cost} is computed from this data.
\item The whole process is then repeated for other \textcolor{blue}{ value of $s$}, producing a confident interval for mean cost for each quantity, $s$.
\item These estimates can be \textcolor{blue}{plotted} and the plot used to locate the \textcolor{green}{minimum value}
\end{itemize}
\end{exampleblock}
\end{frame}
%------------------
\begin{frame}{Algorithm for simulation}
\begin{block}{}
\begin{itemize}
\item The algorithm for the simulation is
\begin{enumerate}
\item For $j=1,2,\ldots,n$ do:\\
To generate $D$ from the distribution of demand\\
Compute: $Y_j=\begin{cases}
10.0(s-D),&\text{if}\,\,D\le s\\
40.0(D-s),&\text{if}\,\,D>s
\end{cases}$\\
Accumulate the sum and sum of squares of the $Y_j$'s.
\item Compute the sample mean of the $Y_j$'s and a confidence interval for the mean.
\end{enumerate}
\item The simulation was run for each values of $s=5.0,6.0,\ldots,12$, using 4000 replications.
\item Fig 2.17 gives the results of the simulation and presents them graphically.
\item The minimum mean cost appears to be obtained $\approx$ 8.0 canisters.
\item Hillier \& Lieberman (1995) solved and determine the exact solution of s, using $F(s*)=\frac{40.0}{40.0+10.0}=0.80$
\end{itemize}
\end{block}
\end{frame}
%------------------
\begin{frame}{Results of multiply runs for inventory model}
\begin{figure}[!h]
\includegraphics[width=0.6\textwidth]{fig2_17.jpg}
\end{figure}
\end{frame}
%--------------
\begin{frame}{Cont..}
\begin{figure}[h!]
%\centering
%\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=0.5\textwidth]{fig2_17a.jpg}
% \caption{}\label{pro2}
%\end{minipage}
\end{figure}
%\end{frame}
\end{frame}
%--------------
\begin{frame}{Cont..}
\begin{block}{}
\begin{itemize}
\item Where $F(x)$ is the \textcolor{blue}{cumulative distribution} function of demand.
\item Because the distribution cumulative of demand is exponential, $f(x)=1-e^{\frac{x}{5.0}}$, and $s^*=5\ln(5)=8.05$.
\item We see that the simulation give us a valid and rather accurate to this problem.
\end{itemize}
\end{block}
\end{frame}
%-------------------------
\begin{frame}{Explanation of Statistical Analysis}
\begin{itemize}
\item Standard error=$\frac{\sigma}{\sqrt{n}}$
\item error=$z_\alpha\frac{\sigma}{\sqrt{n}}$
\item $(1-\alpha)$\% Confidence interval (C.I) for $\mu$:
$\bar{x}-z_{\frac{\alpha}{2}}\frac{\sigma}{\sqrt{n}}\le \mu\le \bar{x}+z_{\frac{\alpha}{2}}\frac{\sigma}{\sqrt{n}}$
\item Lower C.I: $\bar{x}-z_{\frac{\alpha}{2}}\frac{\sigma}{\sqrt{n}}$
\item Upper C.I: $\bar{x}+z_{\frac{\alpha}{2}}\frac{\sigma}{\sqrt{n}}$
%\item
\end{itemize}
If the parent population is normal and $\sigma^2_x$ is known.
\end{frame}
%------------------------
\begin{frame}{Standard deviation, $\sigma$, using Excel}
\begin{figure}[h!]
%\centering
%\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=0.5\textwidth]{stev.jpg}
% \caption{}\label{pro2}
%\end{minipage}
\end{figure}
%\end{frame}
\end{frame}
%\end{frame}
%---------------
\begin{frame}{$z_\alpha$, using Excel}
\begin{figure}[h!]
%\centering
%\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=0.5\textwidth]{norminv.jpg}
% \caption{}\label{pro2}
%\end{minipage}
\end{figure}
\end{frame}
%-----------------
\section{Solution For 2.6.2 in Manual}
\begin{frame}{Solution for Example 2.6.2 (Manual)}
1. Construct table of Probabilities and Random number intervals for Daily Ace Drill Demand:\\
\begin{tabular}{lllll}
\hline
(1)&(2)&(3)&(4)&(5)\\
Demand for&Frequency&&Cumulative&Interval of\\
Ace Drill&(Days)&Probability&Probability&Rand. Numbers\\
\hline
0&15&0.05&0.05&01 to 05\\
1&30&0.10&0.15&06 to 15\\
2&60&0.20&0.35&16 to 35\\
3&120&0.40&0.75&36 to 75\\
4&45&0.15&0.90&76 t0 90\\
5&30&0.10&1.00&91 to 00\\
&---&---&&\\
&300&1.00&&\\
\hline
\end{tabular}
\end{frame}
%------------------
\begin{frame}{Cont..}
2. Construct table of probabilities and Random Number intervals for \textcolor{blue}{Reorder Lead Time}:\\
\begin{tabular}{lllll}
\hline
(1)&(2)&(3)&(4)&(5)\\
Lad Time&Frequency&Probability&Cumulative&Random\\
(Days)&(Orders)&&Probability&Num. interval\\
\hline
1&10&0.20&0.20& 01 to 20\\
2&25&0.50&0.70&21 to 70\\
3&15&0.30&1.00&71 to 00\\
&---&----&&\\
&50&1.00&&\\
\hline
\end{tabular}
\end{frame}
%-------------
\begin{frame}{The third step}
3. Develop the simulation model: A flow diagram, or flowchart, is helpful in the logical coding procedures for programming this simulation process.
\begin{figure}[h!]
%\centering
%\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=0.5\textwidth]{flow1.jpg}
% \caption{}\label{pro2}
%\end{minipage}
\end{figure}
\end{frame}
%-----------------
\begin{frame}{Cont..}
\begin{figure}[h!]
%\centering
%\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=0.5\textwidth]{flow2.jpg}
% \caption{}\label{pro2}
%\end{minipage}
\end{figure}
\end{frame}
%-------------
\begin{frame}{Step 4}
\begin{block}{}
4. To specify the values that we wish to test.
\begin{itemize}
\item Saad wants to stimulate an order quantity of 10 with a reorder point of 5.
\item Every time the \textcolor{blue}{on-hand inventory level} at the end of the day is \textcolor{green}{5 or less}, Saad will call the supplier and place and order for \textcolor{green}{10 more drills}.
\item If the \textcolor{blue}{lead time is one day}, the order will \textcolor{red}{not arrive the next morning} but at the \textcolor{green}{beginning}
\end{itemize}
\end{block}
\end{frame}
%----------------
\begin{frame}{Step 5}
\begin{block}{}
5. To conduct the simulation, and the Monte Carlo method is used for this.
\begin{itemize}
\item The entire process is simulated for a 10-day period.
\item The following table is filled by proceeding on day (or line) at a time, working from left to right. It is a four-step process.
\begin{enumerate}
\item Begin each simulated day by checking whether \textcolor{green}{any ordered inventory} has \textcolor{blue}{just arrived}(column 2). If has increase the \textcolor{blue}{current inventory}(in column 3) by quantity ordered (10 units, in this case.
\item Generate a daily demand from the \textcolor{blue}{demand probability} by selecting a random number. This random number is recorded in column 4. The \textcolor{blue}{demand simulated} is recorded in column 5.
\item Compute the \textcolor{blue}{ending inventory} every day and record it in column 6. Ending inventory=beginning inventory -demand. If \textcolor{blue}{on-hand inventory is insufficient} to meet the day's demand, satisfy as much as possible and note the number of \textcolor{blue}{lost sales} (in column 7).
\item Determine whether the day's ending inventory
\end{enumerate}
\end{itemize}
\end{block}
\end{frame}
%-----------------
\begin{frame}{Cont..}
\begin{block}{}
has reached the reorder point (5 units). If it \textcolor{green}{has} and if there are \textcolor{blue}{no outstanding orders} , place an order (column 8). \textcolor{blue}{Lead time} for a new order is simulated by choosing a \textcolor{blue}{random variable from the given table} and recording in column 9. We can continue down the same string of random number table that we were using to generate numbers for the \textcolor{blue}{demand variable}.. Finally, we convert this random variable into a lead time by using the distribution set in the given table.
\end{block}
\end{frame}
%-------------
\begin{frame}{Simulation}
\begin{figure}[h!]
%\centering
%\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=0.8\textwidth]{saad.jpg}
% \caption{}\label{pro2}
%\end{minipage}
\end{figure}
\end{frame}
\begin{frame}{Cont..}
\begin{block}{}
\begin{description}
\item a) The average daily demand=$\frac{1+4+4+3+3+3+3+3+2+3}{10}=\frac{29}{10}=2.9\approx 3$ units per day
\item b) The average lost sales=$\frac{2\,\, sales \,\,lost}{10}=0.2$ unit per day.
\item c) The number of order placed=3 orders
\item d) The probability that demand per day that exceed 3 units=$\frac{2}{10}=0.2$
\end{description}
\end{block}
\end{frame}
%------------------
%\begin{frame}
\begin{frame}
\begin{figure}[h!]
%\centering
%\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=0.5\textwidth]{uitm2.jpg}
% \caption{}\label{pro2}
%\end{minipage}
\end{figure}
\end{frame}
\end{document}