Search code examples
c#mathvalueconverterpoisson

Can smbd help me to convert some values from real to virtual


I have very strange but very important question for me. So if you have some free minutes - read next sentences.

My mission is: generate values (times) for incoming and outcoming cars on the road. And, from real world I have some variables: length of the road (2000 metres), av.l. of the car (6 metres), time of the experiment (12 hours), and intensities of incoming and outcoming traffic (quantity of cars in 1 hour).
I need to convert all these variables to machine, knowing that time in loop is equal 10 units. Step in loop is 1.

10 units = 12 hours  
1 units = 1.2 hours (72 minutes)   
1 minutes = 0.013888..  

So I must multiply all my intensities by 1.2? Or not? Also I have no idea how to input length of the road into programm. Should I enter 2000 or not... Please, help me, if you can.

Here are functions of generate random numbers

static double RandTimeIn(Random ran, int lambdaMu)
    {
        double t = 0, r = 0;
        r = ran.NextDouble();
        t = (-1) * Math.Log(r, Math.E) / lambdaMu;
        t *= 60.0 / 72.0;
        return t;
    }
    static double RandTimeOut(Random ran, int Mu) //t from [1.5; 12]
    {
        double t = 0, r = 0;
        t = 1.5 + ran.NextDouble() * (12.0 - 1.5);
        t *= 1.0/72.0; 
        return t;
    }

Main pool:

//step=1.0; T=10.0;
for (double i = step; i <= T; i += step)
        {...
        tin = RandTime(ran, lambdaTat3);
        Tin += tin;
        ...
        CarCount=333; //2000/6. Is it right????? Maybe 333/6
        if (CarCount3 < CarCount) //if the road is not full
                    {...
                        CarCount3++;
                        tInArrTat1.Add(Tin);
                        tout = RandTimeOut(ran, mu3);
                        Tout = Tin + tout;
                        ...}
        else {Error++;}
        }

I want to know what variables I must enter in length of the road and length of the object.


Solution

  • There is no real predefined way to convert real world data to perfect virtual data.

    It really depends on what you are trying to get out of the data (and more specifically how precise you want the answers and how efficient the algorithm must be), also is the size of the input massive, if your talking a single day (or 12 hours), I wouldn't think so (but that's just a guess). Type double gives you the best precision for most practical application (BEWARE of floating point error, definitely look into it if you're not familiar). If you need more (meaning EXTREMELY) precise, look into BigInt and BigRational (maybe). WARNIGN, these will most likely become a hassle to use if you don't need the precision. Using these will overkill I feel for your application.

    If you're speaking generally, then it all you have to to do is adhere to a standard (meaning do whatever you feel is necessary), then next thing you have to do is make sure you adhere to whatever unit (standard) you decide to use.

    (ASSUME / means "or") Mathematically speaking, you can leave all lengths in meters and adhere to either meters/cars per unit or meters/cars per hour for speed and frequencies respectively to keep things simple. If you want by-unit measurement, just divide but the 10, if you want by hour, divide by 12. Since you left everything in terms of units/hours then all you have to do is divide by the speed to get the time in units/hours respectively for how long the car will stay in the length of the road (if going at that average velocity).