select date time pairs where time difference is within 1 minute - c#-4.0

I am using excel with C#.
I have two date time lists in excel.
Goal is to select date time pairs from both list where the time difference is less than or equal to 1 minute.
From above image, T1 will come with those values from Time List2 where difference between T1 and any (TA or TB or TC etc) is within 1 min.
Let us say, difference between T1 and (TC and TA) qualifies. So pairs will be: T1/TC and T1/TA
Since both lists are quite long, I am trying to avoid 'for' loop.
Any easy way to get here?
Many thanks!!
P.S - can this be achieved in some other language? I am familiar with python and oracle and will try to understand if solution in any other language is possible.

Related

How to use the value of a running pace in LibreOffice Calc?

So basically, I have a sheet where speeds in kilometers per hour (km/h) are written in cells.
I sometimes convert these speeds into paces (in minutes per kilometer (mn/km)).
To do so, I apply the integer function to an inverse function used on the speed divided by 60 -> INT(1/(speedCell/60)). This gives me the minutes part of the pace.
For example, let's admit that I have a speed of 13 km/h; the pace of that speed is 4'36/km.
The formula gives me the minutes : =INT(1/(13/60)) -> 4.
Now I need to get the seconds part. I do it using the truncate function over the subtraction of the speed converted directly into a pace and the integer part of the pace.
Formula applied : =TRUNC((1/(13/60)-INT(1/(13/60)))*60) -> 36.
Simplified, this is : =PACE(minutes and seconds)-PACE(minutes) -> seconds.
Here comes the problem. I format these two formulas into : =FORMULA1&"'"&FORMULA2"/km".
My question is : How can I use the result, now that it is being formatted with a string in the middle of the formula?
I used to use the format styling to add a unit behind the value; but since there is an apostrophe in the middle of the formula, I don't know how to do it.
Thank you for your help, don't hesitate to ask, if you have questions over the understanding of the problem.
I'm not sure if I understood correctly. But instead of concatenating the pace parts "manually", I recommend building a time value from the minutes / seconds values using the TIME(hours ; minutes ; seconds) function. Now, you can use the cell formatting templates to generate an output like [min]'[sec]/km with the following format code
MM'SS"/km"
and do calculations.
BTW: you could also use the MOD() function to get the seconds part:
=INT(MOD((1/(13/60));1)*60)

How can I obtain hourly readings from 24 hour moving average data?

I have an excel dataset of 24-hour moving averages for PM10 air pollution concentration levels, and need to obtain the individual hourly readings from them. The moving average data is updated every hour, so at hour t, the reading is the average of the 24 readings from t-23 to t hours, and at hour t+1, the reading is the average of t-22 to t+1, etc. I do not have any known data points to extrapolate from, just the 24-hour moving averages.
Is there any way I can obtain the individual hourly readings for time t, t+1, etc, from the moving average?
The dataset contains data over 3 years, so with 24 readings a day (at every hour), the dataset has thousands of readings.
I have tried searching for a possible way to implement a simple excel VBA code to do this, but come up empty. Most of the posts I have seen on Stackoverflow and stackexchange, or other forums, involve calculating moving averages from discrete data, which is the reverse of what I need to do here.
The few I have seen involve using matrices, which I am not very sure how to implement.
(https://stats.stackexchange.com/questions/67907/extract-data-points-from-moving-average)
(https://stats.stackexchange.com/questions/112502/estimating-original-series-from-their-moving-average)
Any suggestions would be greatly appreciated!
Short answer: you can't.
Consider a moving average on 3 points. And even consider we multiply each MA term by 3, so we really have sums of consecutive
Data: a b c d e f g
MA a+b+c
b+c+d
c+d+e
d+e+f
e+f+g
With initial values, you can do something. To find the value of d, you would need to know b+c, hance to know a (since a+b+c is known). Then to find e, you know c+d+e and d, so you must find c, and since a is already needed, you will need also need b.
More generally, for a MA of length n, if you know the first n-1 values (hence also the nth, since you know the sum), then you can find all subsequent values. You can also start from the end. But basically, if you don't have enough original data, you are lost: there is a 1-1 relation between the n-1 first values of your data and the possible MA series. If you don't have enough information, there are infinitely many possibilities, and you can't decide which one is right.
Here I consider the simplest MA where the coefficient of each variable is 1/n (hence you compute the sum and divide by n). But this would apply to any MA, with slightly more complexity to account for different coefficients for each term in the sum.

Excel - Multiple Conditions with 2 variables

I am working on a excel data set whereby I have two variables -
1) One time Spend
2) Installment Spend.
Now, the observations under these two variables contain 4 possibilities.
A - One time Spend>0,Installment Spend=0
B - One time Spend=0,Installment Spend>0
C - One time Spend=0,Installment Spend=0
D - One time Spend>0,Installment Spend>0.
I want to create a new variable called Spend type which can classify the Spend based on
A-Onetime Spend,
B-Installment Spend,
C-No Spend,
D-Both One time and Installment.
Can anybody help me with creating this new variable in excel?
enter image description here
Do you mean like a formula? I have added an invalid category in case of empty cells.
=IF(OR(ISBLANK(A2),ISBLANK(B2)),"invalid",IF(AND(A2=0,B2=0),"No spend",IF(AND(A2>0,B2>0),"Both",IF(AND(A2=0,B2>0),"Installment spend","One time spend"))))
Here is a slightly different formula approach:
=INDEX({"No Spend","Onetime Spend","Installment Spend","Both One time and Installment"},MATCH((A2>0)+(B2>0)*2,{0,1,2,3},0))
Or this shorter version:
=CHOOSE((A2>0)+(B2>0)*2+1,"No Spend","Onetime Spend","Installment Spend","Both One time and Installment")

Create exchanges with bounded random parameters and fixed sum to be used in Montecarlo

I have to run a montecarlo where, for some products, certain exchanges are relate to each other in the sense that my process can take as input any of the products in different (bounded) proportions but with fixed sum.
Example:
my product a takes as inputs a total of 10 kg of x,y, and z alltogheter and x has a uniform distribution that goes from 0 to 4 kg, y from 1 to 6 and z from 3 to 8 with their sum that must be equal to 10. So, every iteration I would need to get a random number for my three exchanges within their bounds making sure that their sum is always 10.
I have seen that in stats_array it is possible to set the bounds of the distributions and thus create values in a specified interval but this would not ensure that the sum of my random vector equals the fixed sum of 10.
Wondering if there is already a (relatively) straightforward way to implemented this in bw2
Otherwise the only way I see this feasible is to create all the uncertainity parameters with ParameterVectorLCA, tweak the value in the array for those products that must meet the aforementioned requirements (e.g with something like this or this) and then use this array with modified parameters to re-run my MC .
We are working on this in https://github.com/PascalLesage/brightway2-presamples, but it isn't ready yet. I don't know of any way to do this currently without hacking something together by subclassing the MonteCarloLCA.

Statistical method for time-course data comparison

I have a question for statistical method which i cant find in my textbook. I want to compare data of two groups. For example, both group have data of day 0, but one group have data of day 2, and another day 6. How can I analyse the outcome with the data and the date? i.e. I want to show that the if data taken on day XX are YY, it has an impact on the outcome.
Thanks in advance.
I'd use a repeated measures ANOVA in this case. However, since you don't have a complete dataset, day X and Y would be just operationalized as the endpoint of your dependent variable. If you'd have measures of all days I'd include.all of them in the analysis in order to fully compare the two timelines. You could then also compare the days of interest directly by using post-hoc tests (e.g. Bonferroni)

Resources