This document provides a quick guide to simulating continuous and discrete uniform demand in R. It includes instructions on downloading R, setting parameters for the simulations, generating random demands from uniform distributions, and testing ordering policies to minimize costs by calculating the mean of costs per period. The document contains two examples: one that simulates continuous uniform demand between 20 and 40 units, and another that simulates discrete uniform demand that can be 5, 10, 15, 20, 25, or 30 units.
This document provides a quick guide to simulating continuous and discrete uniform demand in R. It includes instructions on downloading R, setting parameters for the simulations, generating random demands from uniform distributions, and testing ordering policies to minimize costs by calculating the mean of costs per period. The document contains two examples: one that simulates continuous uniform demand between 20 and 40 units, and another that simulates discrete uniform demand that can be 5, 10, 15, 20, 25, or 30 units.
This document provides a quick guide to simulating continuous and discrete uniform demand in R. It includes instructions on downloading R, setting parameters for the simulations, generating random demands from uniform distributions, and testing ordering policies to minimize costs by calculating the mean of costs per period. The document contains two examples: one that simulates continuous uniform demand between 20 and 40 units, and another that simulates discrete uniform demand that can be 5, 10, 15, 20, 25, or 30 units.
This document provides a quick guide to simulating continuous and discrete uniform demand in R. It includes instructions on downloading R, setting parameters for the simulations, generating random demands from uniform distributions, and testing ordering policies to minimize costs by calculating the mean of costs per period. The document contains two examples: one that simulates continuous uniform demand between 20 and 40 units, and another that simulates discrete uniform demand that can be 5, 10, 15, 20, 25, or 30 units.
Go to https://www.r-project.org/ Select your preferred CRAN mirror and download R based on your operation system.
Continuous Uniform Demand Simulation
# Setup parameters Cp =2; Cv = 1; Cs = 0.5; # How many random demands will be generated? n = 100000; #Generate n random demands from the uniform distribution Demand = runif(n, min = 20, max = 40); #Test the policy where we order 100/3 gallons for every period y = 100/3; mean(Cp*pmin(y,Demand) + Cs* pmax(y-Demand,0) - Cv*y)
Discrete Uniform Demand Simulation
# Setup parameters Cp =1; Cv = 0.25; Cs = 0; # How many random demands will be generated? n = 100000; #Generate n random demands from the discrete uniform distribution Demand = sample(c(5,10,15,20,25,30),n,replace=TRUE,c(1/8,1/8,1/8,1/8,1/4,1/4)); #Test the policy where we order 25 copies for every period y = 25; mean(Cp*pmin(y,Demand) + Cs* pmax(y-Demand,0) - Cv*y)