0
$\begingroup$

Dear crossvalidated community,

quite frankly, I'm not that much into statistics and therefore, I'm having much trouble solving some issues im having in Matlab right now. My plan is to imitate/simulate some realistic driving patterns of costumer in a car sharing simulator. Therefore, I picked a logarithmic probability distribution that represents/models the desire to rent a car once in a while.

So as of now, I have 500 customer that are devided into three different types of customers with different mean intervals:

if  hourOfDay > 20 || hourOfDay < 9 % night

                if obj.custType == 1
                    meanInterval = 45*24*60;
                    stDev = meanInterval/10;
                    MU = log(meanInterval^2 / sqrt(stDev^2+meanInterval^2));
                    SIGMA = sqrt(log(stDev^2/meanInterval^2 + 1));
                    obj.minInterval = lognrnd(MU,SIGMA);

                elseif obj.custType == 2
                    meanInterval = 30*24*60;
                    stDev = meanInterval/8;
                    MU = log(meanInterval^2 / sqrt(stDev^2+meanInterval^2));
                    SIGMA = sqrt(log(stDev^2/meanInterval^2 + 1));
                    obj.minInterval = lognrnd(MU,SIGMA);

                elseif obj.custType == 3
                    meanInterval = 25*24*60;
                    stDev = meanInterval/9;
                    MU = log(meanInterval^2 / sqrt(stDev^2+meanInterval^2));
                    SIGMA = sqrt(log(stDev^2/meanInterval^2 + 1));
                    obj.minInterval = lognrnd(MU,SIGMA);
                end

            else %daytime
                if obj.custType == 1
                    meanInterval = 7*24*60;
                    stDev = meanInterval/5;
                    MU = log(meanInterval^2 / sqrt(stDev^2+meanInterval^2));
                    SIGMA = sqrt(log(stDev^2/meanInterval^2 + 1));
                    obj.minInterval = lognrnd(MU,SIGMA);

                elseif obj.custType == 2
                    meanInterval = 20*24*60;
                    stDev = meanInterval/9;
                    MU = log(meanInterval^2 / sqrt(stDev^2+meanInterval^2));
                    SIGMA = sqrt(log(stDev^2/meanInterval^2 + 1));
                    obj.minInterval = lognrnd(MU,SIGMA);

                elseif obj.custType == 3
                    meanInterval = 15*24*60;
                    stDev = meanInterval/9;
                    MU = log(meanInterval^2 / sqrt(stDev^2+meanInterval^2));
                    SIGMA = sqrt(log(stDev^2/meanInterval^2 + 1));
                    obj.minInterval = lognrnd(MU,SIGMA);
                end

the "obj.mininterval" is the key factor here (determined by the logarithmic prob. density function) and is used to determine whether they want to drive or not:

hasNotDriven = customers{cc}.minInterval < tt - customers{cc}.lastNightDrive;

(in case that the mininterval is lower than the current time of the simulation minus their last rental, they start driving)

For example in this code, customer type 1 is supposed to drive once a week (plus/minus a little deviation so that it's a more or less random pattern) at daytime and, if it is nighttime, each 45 days.

In order to avoid that all customers start driving immediately after I started the simulation, I randomly defined when they drove the last time (e.g.):

if obj.custType == 1
                obj.lastDayDrive = -(4*24*60)*rand(1)*rand(1);
                obj.lastNightDrive = -(42.234*24*60)*rand(1)*rand(1);

However, they don't abide by my rules and keep driving and renting cars like it's their sole purpose in life (they drive far more often than just once a week). Have a look at the following image:

http://imgur.com/6H5UyqM

the green parts of the figure represent daytime and the black ones nighttime.

I'm well aware that my request is rather confusing but please feel free to ask as much as you require. I mean I clearly defined the mean, so why do I keep having these spikes?! I mean, as you can see it's more like all 500 customers drive once a week although, from the various mean intervals, they should be driving far less often (solely customer type 1 is supposed to drive once a week, the other customer types should drive like once every twenty days or so; thus, I consider the mininterval to be lower than it actually should be).

edit: lowering the standard deviation didn't help either:

enter image description here

$\endgroup$
  • $\begingroup$ Looking at your code I can't help but wondering whether you meant lognormal distribution rather than logarithmic distribution. $\endgroup$ – Glen_b -Reinstate Monica Aug 14 '14 at 23:41
  • $\begingroup$ I suppose I did :) However, I found the mistake and it had nothing to do with the choice of distribution. For anyone interested, I'll write an answer! $\endgroup$ – Atlan Aug 15 '14 at 14:26
1
$\begingroup$

At long last, I found the problem. The distribution was fine, but since the iteration kept advancing (tt, symbolizing the minutes,increased) no matter if it was day or night, my condition when a customer wants to drive during the day (day, NOT night) had some unwanted impacts:

hasNotDriven = customers{cc}.minIntervalday < tt - customers{cc}.lastDayDrive;

so some people decided that they would like to drive (since tt, which kept increasing, minus the last drive suddenly became higher than the lastminIntervalDay) even though it was night. But since the customers are not allowed to drive while its nighttime (when their real intention is to drive during the day), they waited and started driving immediately when it became day.

Therefore, I had to implement two additional variables ttday and ttnight, which only increased when it was day/night.

hasNotDriven = customers{cc}.minIntervalday < ttday - customers{cc}.lastDayDrive;
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.