123

McMillan's Running Calculator (Read 2818 times)

    Here is some octave/matlab code which I made a few weeks a go for predicting running times when the coefficients are uncertain. It assumes that the coefficients are stationary over the intervals and it will show estimated minimum and maximum times with 90% confidence. It needs a running.dat file with appropriate values filled in for s (distance, in meters) and t (time, in seconds). ## -*- Mode: octave -*- ## Copyright 2007, Christos Dimitrakakis ## Calculation of the formula ## u = c * d^(-a) ## with unknown c, a. 1; ## speed, distance, speed factor, distance factor. function log_p = log_p_u(u, s, c, a) u_predicted = c .* s .^(-a); delta = (u_predicted - u); log_p = -delta.*delta; end ## use a gamma prior for a to encourage small values near 0.06 function log_p = log_prior_a(a) ## log_p=-1000; ## if (a>=0) ## log_p = log(gamma_pdf(5,.3,a)); ## end log_p=0; end load running.dat error_p=0.05; distances=[100 200 400 500 800 1600 3200 4000 5000 10000]'; n_distances=length(distances) Eu = zeros(n_distances,1); u_ML = zeros(n_distances,1); u_hconf = zeros(n_distances,1); u_lconf = zeros(n_distances,1); ## We will do this a la function space view of stochastic processes: ## 1 - Make a vector C for all possible values of c c = s./t; m = length(c); ## 2 - make a vector for a a = [1:20]/100; n = length(a); ## 3 - make a posterior matrix for our paramters c,a logP=zeros(m,n); for i=1:m for j=1:n for k=1:m ## the double appearence of c suggests the possibility of using a ## covariance matrix approach instead logP(i,j) += log_p_u(c(k), s(k), c(i), a(j)) + log_prior_a(a(j)); end end end for distance_index=1:n_distances s_in = distances(distance_index); ## look at speeds between u_min, u_max only u_min = min(c)*s_in.^(-max(a)); u_max = max(c)*s_in.^(-min(a)); ## subdivide into N possible speeds N=100; u = zeros(N,1); Pu = zeros(N,1); max_P = logP(1,1); argmax_c = 1; argmax_a = 1; Eu(distance_index) = 0; Z = 0; for k=1:N alpha = (k-1)/(N-1); u(k) = (1 - alpha)*u_min + alpha*u_max; ## Given the parameter matrix, calculate the probability of the speed for i=1:m for j=1:n ## sum [p(u|d, c,a) p(c,a)] Pu(k) += exp(log_p_u(u(k), s_in, c(i), a(j)) + logP(i,j)); if (logP(i,j) > max_P) max_P = logP(i,j); argmax_c = i; argmax_a = j; end end end ##printf ("u:%f t:%f p:%f\n", u(k), s_in/u(k), Pu(k)); Eu(distance_index) += u(k) * Pu(k); Z += Pu(k); fflush (stdout); end Eu(distance_index) /= Z; u_ML(distance_index) = c(argmax_c) * s_in ^ (-a(argmax_a)); Pu = Pu / sum(Pu); u_lconf(distance_index) = u(max(find(cumsum(Pu)<error_p)));>1-error_p))); printf("%dm ", s_in); ##printf("E[u]=%f, u_ML=%f (m/s) ", Eu(distance_index), u_ML(distance_index)); printf("E[t]=%f, t_ML=%f (min) ", s_in/Eu(distance_index)/60, s_in/u_ML(distance_index)/60); ##printf("90%% credible interval: [%f %f] (m/s)", ##u_lconf(distance_index), ## u_hconf(distance_index)); printf(" [%f %f] (min)\n", s_in/60/u_lconf(distance_index), s_in/60/u_hconf(distance_index)); hold off; plot(distances, Eu,';E;') hold on; plot(distances, u_ML,';ML;') plot(distances, u_lconf,';90%;') plot(distances, u_hconf,';90%;') end printf ("c_ML=%f, a_ML=%f\n", c(argmax_c), a(argmax_a)); hold off; plot(distances, distances/60./Eu,'1;E;') hold on; plot(distances, distances/60./u_ML,'2;ML;') plot(distances, distances/60./u_lconf,'3;90%;') plot(distances, distances/60./u_hconf,'3;90%;') plot(s,t/60,'4@;data;') </error_p)));>
    jEfFgObLuE


    I've got a fever...

      It needs a running.dat file with appropriate values filled in for s (distance, in meters) and t (time, in seconds).
      Sweet. I have Matlab at work -- I want to try this out. In the running.dat file, are the values separated by commas or spaces or something? I'm envisioning a data file that looks like: s1, t1 s2, t2 ... ... sn, tn Also, I'm not familiar with octave. Do I need to change that first line to run in Matlab? Cheers, Jeff

      On your deathbed, you won't wish that you'd spent more time at the office.  But you will wish that you'd spent more time running.  Because if you had, you wouldn't be on your deathbed.

      Mishka-old log


        Olethros has clearly outdone "geekery" Shocked. I think we need a new word to describe this new level of geekdom that has been barfed upon us.


        Why is it sideways?

          And I thought I was a geek when I started keeping an online running log. It was matlab that made me hate diff. equations in college. You guys play with this for fun?? I don't know whether to be impressed or deeply, deeply saddened. Wow.
            Sweet. I have Matlab at work -- I want to try this out. In the running.dat file, are the values separated by commas or spaces or something? I'm envisioning a data file that looks like: s1, t1 s2, t2 ... ... sn, tn Also, I'm not familiar with octave. Do I need to change that first line to run in Matlab? Cheers, Jeff
            It should work in matlab as is, but I don't actually have matlab since it is not free. Perhaps you need to replace the # characters with %, note sure. The octave/matlab compatibility is not 100%, sadly. Actually there is a bug in the code, since I am not considering high values of speed thus giving high probability to you going very slowly (yes, silly of me, I know). A modified version that fixes that can be found here The data file can look like this (no, these are not real times): # Created by Octave 2.9.9, Mon Feb 26 15:40:57 2007 CET <cdimitrakakis@ginfra08.unileoben.ac.at> # name: s # type: matrix # rows: 9 # columns: 1 400 800 1600 2000 3000 3200 4000 5000 10000 # name: t # type: matrix # rows: 9 # columns: 1 80 167 348 441 677 725 919 1164 2426 </cdimitrakakis@ginfra08.unileoben.ac.at>
              This thread is making my head hurt Tongue ! (I went to law school so I wouldn't have to do math Blush )
              2009: BQ?
                It's just basic statistics. It just looks complicated.
                muse_runner


                keep running.

                  I loooooove McMilly. I know what Matlab is and my podunk school is trying to get it. wow.... i'm impressed with you boys! Trishie a law degree is no walk in the park or anything, it's like a marathon!
                  running until I hit 1900 miles for the year. whether fast or slow I will just run.
                    It's just basic statistics. It just looks complicated.
                    Because I can't read Matlab code. Are you just running a basic confidence interval? The coefficents, what values/howd you derive them/where do they go with the data? I'm interested as I'd just been doing a confidence interval for my mean 5k time with out bothering to check any sort of assumptions and it was okay and I'd like to tweak it.
                      Because I can't read Matlab code. Are you just running a basic confidence interval? The coefficents, what values/howd you derive them/where do they go with the data? I'm interested as I'd just been doing a confidence interval for my mean 5k time with out bothering to check any sort of assumptions and it was okay and I'd like to tweak it.
                      It is mostly explained in the comments, but here goes. I am using the formula t = c*d^(-a), where d is the given distance and c, a are unknown constants. I am using a bayesian approach where I am putting a prior probability distribution over possible values of c (which basically corresponds to your maximum speed) and a (which basically corresponds to how fast your speed degrades as distance increases). The prior distribution for a is centered around 0.06, so as to correspond with a well-known running formula, but all values >=0 are possible. After taking a look at the data, the code determines the probability for each possible pair of values of c,a being the 'true' ones, i.e. the posterior distribution for these variables. Afterwards it's easy to calculate confidence intervals. Just look at the c,a pairs which are at the top/bottom x% of the probability mass. (I am not doing this analytically, I literally have a bunch of c,a pairs for which I calculate a posterior density. Much simpler, but the code is slower). This type of confidence interval is usually called a 'credible interval' Again, look at the code here, since the one I originally posted never considers high enough values for c: http://www.idiap.ch/~dimitrak/downloads/running_formula.m
                      Scout7


                        Ye flipping gods, I am sooooooo glad I just write business applications.......
                          oh man, mcmillan has me coming in at like 1:40 on my Half Marathon. I DON'T THINK I CAN DO THAT.
                          jEfFgObLuE


                          I've got a fever...

                            oh man, mcmillan has me coming in at like 1:40 on my Half Marathon. I DON'T THINK I CAN DO THAT.
                            The McMillan calculator, like all running calculators, has to be taken with a grain of salt. The further your starting distance is from the predicted performance, the more uncertainty i.e. if the 1:40 half is predicted from a recent 10 mile race, it's more believable than if predicted from a 5k. The big caveat that's usually not made clear is that the predicted times are times you could run if you embark on specific training for those distances. Working your number backwards: let's say you've been training for a 5k, doing 5k-specific workouts, and you crank out a PR of 21:38. McMillan says that's equivalent to a 1:40 half. But does that mean you could go out the next weekend and do it? No -- it means that from where you are now with the 21:38, if you embarked on say an 8-12 plan of half-marathon specific training, the 1:40 would be attainable. Cheers, Jeff

                            On your deathbed, you won't wish that you'd spent more time at the office.  But you will wish that you'd spent more time running.  Because if you had, you wouldn't be on your deathbed.

                              thanks! I have been doing half specific training so I think I can go like maybe 1:46 or so? When I use this site's calculator with my 10k PR (46:00) it has me at more like 1:42 which is a little more reasonable?
                              jEfFgObLuE


                              I've got a fever...

                                thanks! I have been doing half specific training so I think I can go like maybe 1:46 or so? When I use this site's calculator with my 10k PR (46:00) it has me at more like 1:42 which is a little more reasonable?
                                Yeah, if your 10k is recent, or you think you could do it again now, I think the 1:42 is attainable. (and more believable -- like I said, the closer the two distances are, the more accurate the prediction). Good Luck! Smile

                                On your deathbed, you won't wish that you'd spent more time at the office.  But you will wish that you'd spent more time running.  Because if you had, you wouldn't be on your deathbed.

                                123