function IEOR161HW5 - %for y = .75 for i = 1:10000; offer =...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
function IEOR161HW5() clear all close all clc %plots l=10; m=1/0.8; c=1; lambda = .1:.5:20; mu= .1:.1:2; cost=.1:.1:2; y1= zeros(1,length(lambda)); y2a= zeros(1,length(mu)); y2b= zeros(1,length(mu)); y2= zeros(1,length(mu)); y3= zeros(1,length(cost)); y1= 1/m*log(lambda/(m*c)); y2a= 1./mu; y2b= log(l./(mu*c)); y2=y2a.*y2b; y3= 1/m*log(l./(m*cost)); figure(1) plot(lambda,y1); figure(2); plot(mu,y2); figure(3); plot(cost,y3); %simulation y_optimal = 1/m*log(l/(c*m)); ya = .75; yb = 3; profit = zeros(1,10000); %for y_optimal for i = 1:10000; offer = -1/m*log(1-rand); arrival = -1/l*log(1-rand); while offer<y_optimal; offer = -1/m*log(1-rand); arrival = -1/(exp(-m*y_optimal)*l)*log(1-rand); end profit(i) = offer-arrival*c; end figure(4); hist(profit,150); average = mean(profit); sd = std(profit); percent5 = average-2*sd; percent95 = average+2*sd; stats_opt = [average, sd, percent5, percent95]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %for y = .75 for i = 1:10000; offer = -1/m*log(1-rand); arrival = -1/l*log(1-rand); while offer&lt;ya; offer = -1/m*log(1-rand); arrival = -1/(exp(-m*ya)*l)*log(1-rand); end profit(i) = offer-arrival*c; end figure(5); hist(profit,150); average = mean(profit); sd = std(profit); percent5 = average-2*sd; percent95 = average+2*sd; stats_a = [average, sd, percent5, percent95] %for y = 3 for i = 1:10000; offer = -1/m*log(1-rand); arrival = -1/l*log(1-rand); while offer&lt;yb; offer = -1/m*log(1-rand); arrival = -1/(exp(-m*yb)*l)*log(1-rand); end profit(i) = offer-arrival*c; end figure(6); hist(profit,150); average = mean(profit); sd = std(profit); percent5 = average-2*sd; percent95 = average+2*sd; stats_b = [average, sd, percent5, percent95] end...
View Full Document

This note was uploaded on 03/17/2011 for the course IEOR 161 taught by Professor Lim during the Spring '08 term at University of California, Berkeley.

Page1 / 2

function IEOR161HW5 - %for y = .75 for i = 1:10000; offer =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online