Applying 2 PDFs - 1 for demand and 1 for duration

#1
This is theoretical to help my understanding of stats, but not homework/coursework.

if I have a (lets say) a kayak rental business which is open 24/7 and has no hourly variation in the parameters outlined below, and
  1. The number of customers approaching the stall to rent a kayak each hour follows a Poisson distribution, say with a λ = 0.5
  2. The duration of rental (time before the customer returns the kayak) follows a right skewed distribution of some kind - log normal or inverse gamma - lets say log normal (working in hours as our unit of time):
    μ = ln(2) and σ =ln(1.5)
How many kayaks do I purchase to ensure that 95% of the time a customer approaches the store, I have a kayak available? Put another way, what is my (one-tailed) 95% confidence interval for the number of kayaks out at a given moment, given the 2 probability distributions above?

Thank you for your thoughts and expertise
 
Last edited:
#2
Heres a simple appraisal in discrete time, actual problem involves continuous time and stochastic process, which are a bad combo. Maybe someone smarter than me knwos how to do that. Caveat emptor

we can agree that number of kayaks in stock (Y_{t + 1})= -total left since beginning + total returned
= - ( sum j = 0 to t ( X_j ) ) + (sum j = 0 to t U(t,j)
where Xj is your Poisson var.
and U(t,j) is the number of iid log normals among Xj having values <= t - j. Then U(t,j) is binomial( Xj, Fy( t - j) ), where Fy is log normal CDF.

Taking expectations:
E( U(t,j) ) = E( E( U | Xj) ) = E( Xj Fy(t - j) ) = lambda * Fy(t - j)
E( kayaks in stock at t+1 ) = -t*lambda + lambda * ( sum j = 0 to t Fy( t - j) ) = lambda*( ( sum j = 0 to t Fy( t - j) ) - t )

Of course I allowed your number of kayaks to be negative, thats allowed isn't it?

According to my analysis then you are screwed because if you don't on average put in what on average you get back you are on average not havin nothing, like my bank acount.


I actually think you don't mean confidence interval, but probability.
 
#3
I write up short sas sim to test above formula lambda*( ( sum j = 0 to t Fy( t - j) ) - t ), apparently correct, although i think this is just expression of 'littles law' on googling. I actually give the average change in kayaks in stock Y, ie the number on the river. So I reckon you need at least that many.
You can probably tweak the simulation to give answer of 95% 0 question,

/*


*/


%LET LAMBDA = 5;
%LET MU = 1;
%LET T = 10;
%LET B = 100;

DATA A;
DO SIMN = 1 TO &B;
DO t = 1 to &T;
XJ = RAND('POISSON', &LAMBDA );
DO J = 1 TO XJ;
Y = RAND('EXPONENTIAL', &MU);
RETURNED = . < Y < &t - t;
OUTPUT;
END;

END;
END;
RUN;

PROC SQL;
CREATE TABLE SUMMARY AS SELECT
SUM( XJ * (j=1) ) AS TOTALOUT,
SUM( RETURNED ) AS TOTALIN,

SIMN
FROM A
GROUP BY SIMN ;

QUIT;




DATA RESULT;
SET SUMMARY;
STOCK = TOTALIN - TOTALOUT;
RUN;


PROC MEANS DATA = RESULT;
VAR STOCK;
RUN;


DATA U;
DO j = 0 to &T - 1;
F = 1 - EXP(- j/&MU );
OUTPUT;
END;


RUN;

proc sql;
SELECT
&LAMBDA* ( SUM(F ) - &T )
FROM U;
QUIT;
 
#4
Thank you very much for your time including the simulation. I can't say SAS is something I am overly familiar with, but I believe I can follow it.
 
#5
theres a free 'sas academic' online now. Thanks for the interesting problem, wish i knew more about stochastic series like these. It occurred to be it is probably asymptotically normal, so given the mean and if you could figure the variance you would know everything there is to know!
 

Dason

Ambassador to the humans
#6
Or just use R. So much better for this kind of problem. Also better for literally everything else
 
#7
Honestly it seems half the time Im working in government or industry which tends to be extremely hostile to R on account of being free and not sanctified by FDA, so I have to hear about how writing R programs is anathema to the holy writ, or im dealin with academic types or statiticians who have some sort of axe to grind about R programming. There should just be some kind of 'the stand' type final showdown where everyone beats each other over the head with wiffle bats for the sake of keeping the peace... same applies for Bayesians!
 

Dason

Ambassador to the humans
#8
I mean... If you're siding against R and against Bayesians... I might need to bring out the ban hammer...
 
#9
There should just be some kind of 'the stand' type final showdown where everyone beats each other over the head with wiffle bats for the sake of keeping the peace... same applies for Bayesians!
I mean... If you're siding against R and against Bayesians... I might need to bring out the ban hammer...
Nerd humour, but oh so good - I am chuckling away here on the other side of the world.

R and Stata are definitely my poisons, but as someone once stated (I'll have to paraphrase), no one asks an author what brand of typewriter they use.

Would you mind @fed2 just explaining a couple of things while trying to read the SAS code you kindly presented.
  • I am moderately familiar with SQL, but the statement
    SQL:
    SELECT SUM(  XJ * (j=1) )
    is not one I am familiar with - is (j=1) just a shorthand for the SQL COALESCE(j, 1) statement?
  • As best I can tell, the SQL OUTPUT statement inserts a row/record into the data output with a field/value for each variable in scope. The question is what variables are in scope at the time - I am assuming every variable declared since the DATA statement (as opposed to the variable scope being confined to within the do loop - i.e. block scope) - is this correct?
Thank you
 
#10
Oh this line is just to sum only the unique Xj. The dataset contains one row per kayak, so the poisson variable Xj repeats xj times. j=1 evaluates as 0 (false) or 1 (true). SAS is bizarre, basically nothing about computer programming in real languages applies. this is just the first way that came to mind. Proc sql just creates a dataset with contents of sql query. I don't know if there is scope in this sense in SAS, the query just has to refer to variables that are in the datatset.