Google Sheets - Incorrect result - google-sheets

I am confused with a Google Sheet I created.
https://docs.google.com/spreadsheets/d/1k0osuq_WFztRxNGcxXBhG5Hi6LSrHj8A5RCEwMnQZUs/edit?usp=sharing
These are bike times taken to complete 90 kms. These are split into 5kms chunks.
The interesting thing is that I input the time for each 5km chunk and calculate the speed in km/h from it. Then I calculate the total time taken using sum and the average speed using average. However this is incorrect. For Zell-am-See 2017 I get an average speed of 31km/h when the it should be around 28 km/h.
I can't seem to find the error. Initially I thought it was due to rounding but even if I change the data format to scientific nothing changes.

It is an incorrect assumption about the mathematics. You cannot average the averages (you need total distance over total time) because the lower rates impact the average more than the higher rates because they happen for longer times. You might want to Google "harmonic mean" for more.
For example, suppose you go 120 km at 40 km/h, and then ride back at 30 km/h. You have traveled 240 km in 7 hours. Your average rate is under 35 km/h.
EDIT: Total distance over total time is the way to go. But if you want to satisfy yourself that it is the harmonic mean you want, add a column F to the right of your speeds, and in F3 say =1/E3, and drag that on down through F20. In F21 say =1/AVERAGE(F3:F20), and behold you have the harmonic mean, which is the desired answer.

Related

Hard time finding SARIMA parameters from ACF and PACF

Im a beginner in time series analyses.
I need help finding the SARIIMA(p,d,q,P,D,Q,S) parameters.
This is my dataset. Sampletime 1 hour. Season 24 hour.
S=24
Using the adfuller test I get p = 6.202463523469663e-16. Therefor stationary.
d=0 and D=0
Plotting ACF and PACF:
Using this post:
https://arauto.readthedocs.io/en/latest/how_to_choose_terms.html
I learn to "start counting how many “lollipop” are above or below the confidence interval before the next one enter the blue area."
So looking at PACF I can see maybe 5 before one is below the confidence interval. Therefor non seasonal p=5 (AR).
But I having a hard time finding the q - MA parameter from the ACF.
"To estimate the amount of MA terms, this time you will look at ACF plot. The same logic is applied here: how much lollipops are above or below the confidence interval before the next lollipop enters the blue area?"
But in the ACF plot not a single lollipop is inside the blue area.
Any tips?
There are many different rules of thumb and everyone has own views. I would say, in your case you probably do not need the MA component at all. The rule with the lollipop refers to ACF/PACF plots that have a sharp cut-off after a certain lag, for example in your PACF after the second or third lag. Your ACF is trailing off which can be an indicator for not using the MA component. You do not have to necessarily use it and sometimes the data is not suited for an MA model. A good tip is to always check what pmdarima’s auto_arima() function returns for your data:
https://alkaline-ml.com/pmdarima/tips_and_tricks.html
https://alkaline-ml.com/pmdarima/modules/generated/pmdarima.arima.auto_arima.html
Looking at you autocorrelation plot you can clearly see the seasonality. Just because the ADF test tells you it is stationary does not mean it necessarily is. You should at least check if you model works better with seasonal differencing (D).

How do I create a function that will run input-dependent sums or outcomes in Google Sheets?

I have built a spreadsheet for a game I play. Its purpose is to demonstrate the amount of points earned after each round. The amount of points earned is dependent on the win/loss of that round, and then the points compound or retract accordingly.
There are 24 matches that are played in this game, with a possible result of win/loss for each round. So, there are 48 different individual results that can occur. The complicated thing is that each round's points depends on win/loss, as well as the previous round's individual earnings. For example, if Round 2 is won and earns 120 points, and Round 3 is won, it earns 150 points. But if Round 3 is lost, 120 points is earned.
I am looking to build a program or function that will compute the final score of every one of the 16,777216 possible combination of outcomes.
Thanks in advance!

How to determine periodicity from FFT?

Let's say I have some data that corresponds to the average temperature in a city measured every minute for around 1 year. How can I determine if there's cyclical patterns from the data using an FFT?
I know how it works for sound... I do an FFT of a sound wave and now the magnitude is shown in the Y axis and the frequency in Hertz is shown in the X-axis because the sampling frequency is in Hertz. But in my previous example the sampling frequency would be... 1 sample every minute, right? So how should I change it to something meaningful? I would get cycles/minute instead of cycles per seconds? And what does cycles/minute would mean here?
I think your interpretation is correct - you are just scaling to different units. Once you've found the spectral peak you might find it more useful to take the reciprocal to express the value in minutes/cycle (ie the length of the periodic cycle). Effectively this is thinking in terms of wavelength rather than frequency.

Is it possible to use core motion for distance measurement [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Getting displacement from accelerometer data with Core Motion
Android accelerometer accuracy (Inertial navigation)
I am trying to use core motion user acceleration values, and double integrating them to derive distance covered. I move my iPhone linearly along its Y axis, against a 30 cm log ruler, on the table. First, I let the device be at rest for 10 seconds, and I calculate my offsets along the three axes, by averaging the respective user acceleration values.
The X, Y and Z offsets are subtracted from the acceleration values, when I try calculating the distance covered. After offset subtraction, these values are passed through a low pass filter and a median filter, separately of course. The filters are linear filters, and the cut-off frequency is specified by the number of neighbouring values whose mean is taken in low pass, and median in the median filter. I have experimented with varying values of this number from 1 to 100. In the end, these filtered values are double integrated using trapezoidal rule to get distances. But, the distance calculated is no where close to 30 cm. The closest value I got was some -22 cm(I am wondering why I am getting negative values even though I move the device in positive Y direction). I also came across this:
http://ajnaware.wordpress.com/2008/09/05/accelerating-iphones/
its an old post about the same thing, which says that the accelerometer readings returned appeared to come in quanta of about 0.18m/s^2 (ie. about 0.018g), resulting in a large cumulative error very quickly. Going by that, for this error to really not matter, one will have to accelerate the device by almost 1.8m/s^2, which is practically impossible for distance/length measurement purposes. for small movements, it does not look like there is a possibility of calculating distances by using an optimal filter and a higher order numerical integration method, without an impractical velocity/acceleration constraint like that. Is it possible?
How about using my acceleration vs timestamp data to interpolate a polynomial that grows over time, as I get more and more motion updates, which represents approximately an acceleration vs time curve. Double integration of ths polynomial would be a piece of cake. But, for small distances, the polynomial will have a big error component. Using a predictable known motion that my device will be subjected to, I wish to take a huge number of snapshots (calculated distance vs actual known distance) to calculate my error polynomial in a similar way, and then subtract it from my first polynomial. Can this work?
Although this does not fit StackOverflow, because it's not a question but a discussion, I'll try to sum up my thoughts about it.
As already said, the accelerometer is very inaccurate and you would need very good accuracy for this kind of task, especially if you are trying to measure such short distances. Plus, accelerometers differ from device to device, you will get different results for the same movements with different device. Plus a very huge random error.
My guess is, that you can get rid of a huge part of randomness/error by calibrating the device and making the "measurement move" a couple of times, like 10 times. After that you have enough data to get an average that might get close to the real value.
Calibration is a key part here, you have to think of a clever way to calibrate, like letting the user move the device over different distances in different speeds.
But all this is just theory. I would really like to see your results, but I doubt you get it working good enough even using the best possible filters/algorithms, since there is just too much noise.

How many significant figures do iOS devices calculate current location to?

When an iOS application requests the user's current location, to how many significant figures are the latitude and longitude values returned?
Just looking for the maximum no. of digits for database constraints.
There's no real answer to this. Among other reasons, the accuracy returned by CoreLocation varies and the conversion from degrees to linear distance depends on location.
At this point, I think the lowest accuracy I've seen returned by CoreLocation is 5 meters but in theory this could get better with time.
Wikipedia has a table of conversion from degrees to linear distance at the equator. Six fractional digits gets you down to 10 cm at the equator which is probably higher than the phone is going to provide in the foreseeable future. Five digits gets you to 1 meter but it's not too hard to imagine a future device besting that.

Resources