Arrivals and departures in discrete time

  • Thread starter Thread starter Lobotomy
  • Start date Start date
  • Tags Tags
    Discrete Time
Lobotomy
Messages
55
Reaction score
0
Hello
I have a problem.
im looking at discrete event arrivals of items.

the x-array represents the time of arrival and if one number occurs more than once it obviousely means that more than one item arrives at the exact same time. for instance:

x=[0 0 0 0 3 3 3 3 6 6 6];

this means that 4 items arrives at time 0, 4 more items arrive at time 3 and 3 more items arrive at time 6.

the y-array equals the size of the x-array and represents the accumulated number of items.
y=[1:11];


plotting this for instance in Matlab will show you this graphically:
plot(x,y,'*')


Now the thing is that i have yet another series of measurements, of items leaving. z represents the time they are leaving similar to x. w is the accumulated number of items that has left.

z=[2 2 2 5 5 5 5 5]
w=[1:8]

plotting these together:

hold
plot(z,w,['+','g'])


now what i want to do is the calculate the the amount of items in the system at every discrete time represented in the above vectors, hence the arriving items minus the leaving items. Sounds pretty simple but i can't figure out how to do it! The hard part is because the time scale is different...

so x,y and z,w are given to me beforehand. in reality these are vectors of length 10000, and there might be several arrivals in a row followed by several items leaving in a row, so this is why i can not do it by hand here. But in my small example, the result I am looking for is:



s=[0 0 0 0 2 3 3 3 3 3 5 6 6 6];
a=[1 2 3 4 1 1 2 3 4 5 0 1 2 3];


plot(s,a,['<','r'])

notice that the a-vector must be modified since values are no longer added but subtracted.

the s-vector contains all the times of the x and z vectors, but the amount of items at each time is modified by hand.

My question is, is there a way to calculate s and a from x,y and z,w?? in the above example I've calculated it just by figuring out the result... this seems pretty simple but well i just can't figure out how to do it. please help me someone
 
Mathematics news on Phys.org
I don't know Matlab, but here's my take.

1. Take the union of x and -z: t=[0 0 0 0 -2 -2 -2 3 3 3 3 3 -5 -5 -5 -5 -5 6 6 6]
2. Construct a running sum of the elements in t: b= [1 2 3 4 3 2 1 2 3 4 5 6 5 4 3 2 1 2 3 4], by adding 1 for every non-negative element and subtracting 1 for every negative element in t.
3. Reduce t to s by:
3.a. deleting all except the last one of a sequence of identical negative elements, e.g. -2 -2 -2 (delete the first two 2's, keep the last one)
3.b. multiplying each negative element by -1
4. Reduce b to a by deleting an element if it is less than the previous one, unless the next one is higher. E.g., in "4 3 2 1 2" mark 3 for deletion because 4 > 3 and 3 > 2, mark 2 for deletion because 3 > 2 and 2 > 1, keep 1 because 1 < 2, keep 2 because 1 < 2.
 
EnumaElish said:
I don't know Matlab, but here's my take.

1. Take the union of x and -z: t=[0 0 0 0 -2 -2 -2 3 3 3 3 3 -5 -5 -5 -5 -5 6 6 6]
2. Construct a running sum of the elements in t: b= [1 2 3 4 3 2 1 2 3 4 5 6 5 4 3 2 1 2 3 4], by adding 1 for every non-negative element and subtracting 1 for every negative element in t.
3. Reduce t to s by:
3.a. deleting all except the last one of a sequence of identical negative elements, e.g. -2 -2 -2 (delete the first two 2's, keep the last one)
3.b. multiplying each negative element by -1
4. Reduce b to a by deleting an element if it is less than the previous one, unless the next one is higher. E.g., in "4 3 2 1 2" mark 3 for deletion because 4 > 3 and 3 > 2, mark 2 for deletion because 3 > 2 and 2 > 1, keep 1 because 1 < 2, keep 2 because 1 < 2.

hm ok... thanks ill try, but remember i can't do anywhing "by hand" all this has to be mathematical operations on a vector. since i can't go through the entire vectors manually since they are 10000 values long
 
Lobotomy said:
hm ok... thanks ill try, but remember i can't do anywhing "by hand" all this has to be mathematical operations on a vector. since i can't go through the entire vectors manually since they are 10000 values long
Right; you should be able to come up with a simple algorithm for each individual step in my post.
 
EnumaElish said:
Right; you should be able to come up with a simple algorithm for each individual step in my post.

yes it seems some simple programming is required rather than vector operations
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
Thread 'Imaginary Pythagorus'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...
Back
Top