1

Ok here I am again, the worlds biggest maths noob, I have been wracking my brain over this seemingly simple problem, I am comparing the speeds of different ways of pushing integers to an array in code and I really don't know if I'm doing this correctly.

Here are my values below ordered from fastest to slowest:

listComprehension.py:

$2.503\cdot10^{-5}s$

map.py

$5.364\cdot10^{-5}s$

recursion.py

$3.379\cdot10^{-4}s$

loop.py:

$1.622\cdot10^{9}s$

This is the simple formula I used:

$(\frac{[bigNum]}{[smallNum]})\cdot100$

% speed listComprehension.py vs recursion.py:

$(\frac{[3.379\cdot10^{-4}]}{[2.503\cdot10^{-5}]})\cdot100\Rightarrow 1400\%$

% speed map.py vs recursion.py:

$(\frac{[3.379\cdot10^{-4}]}{[5.634\cdot10^{-5}]})\cdot100\Rightarrow 629\%$

I just want to know if I'm doing the percentages correctly because I don't want to look like an idiot in my readme.

The value for listComprehension.py vs loop.py is ridiculous it’s: $$6.480\cdot10^{15}\%$$

Which makes me think I’m doing something wrong.

edit:

I had an error in the code for loop.py, it's value is actually:

$$9.584\cdot10^{-5}s$$

Final %s & ratios:

## % Comparison of speeds

listComp.py is:

  • 214.3% or ~2:1, faster than map.py
  • 382.9% or ~4:1, faster than loop.py
  • 1400% or 14:1, faster than recursion.py

map.py is:

  • 178.7% or ~2:1, faster than loop.py
  • 629.9% or ~7:1, faster than recursion.py

loop.py is:

  • 352.6% or ~4:1, faster than recursion.py

```

Nickotine
  • 225
  • Is your value for loop.py accurate? You’re saying it takes 1.622 billion seconds... maybe that should be $1.622 \times 10^{-9}$ – tomi May 30 '21 at 05:21
  • 2
    $1.622 \times 10^9$ seconds is over $51$ years. Do you have that right? I don't know why you want percentages instead of ratios, but your calculations are correct. – Ross Millikan May 30 '21 at 05:29
  • hmmm, I think it might actually be milli seconds... I'll put my actual output in. the question – Nickotine May 30 '21 at 05:30
  • sorry guys I had an error in the code for the loop.py... yes It's in seconds the value is 9.584e-05 – Nickotine May 30 '21 at 05:38
  • @RossMillikan I'm using %s because that's what the average person finds eye catching :) – Nickotine May 30 '21 at 05:43

1 Answers1

1

Percentages are probably most useful for relatively small differences encountered in day to day life. E.g. Megamart is 25% cheaper for beans than Minimart or you got a 10% bonus for being the only person in the company who understands percentages.

They work less well as the differences get larger. Most people correctly interpret "100% more" as "twice as much" but it is common to see "500% more" interpreted as "5 times" bigger rather than "6 times".

If your original loop.py time had been correct then it would be far beyond sensible use of percentages. It is not common to say that the proton is $183867\%$ heavier than an electron.

I guess that the idea of percentages is to avoid fractions when describing quite small changes though I often feel that they cause more problems than they solve.

badjohn
  • 8,204
  • If you are interested I'm going to add the final %s to the question as they get formatted badly in the comments, and they are quite large tbh... As a mathemetician in your opinion are fractions and ratios the best way to convey differences?

    I'm not a fan of %s myself but it's what the common man expects and wants

    – Nickotine May 30 '21 at 09:41
  • 1
    In a quite technical case such as this, I'd go for ratios. Someone who is going to understand the subject should understand ratios. Just as in my physics example, percentages don't really help. (Just my opinion, others may still prefer percentages.) – badjohn May 30 '21 at 09:46
  • I agree with you, it's just generally people like their %s... – Nickotine May 30 '21 at 09:51
  • 1
    True but you need to judge when they may confuse more than they help. Have you encountered the "500% more" misinterpretation that I mention? – badjohn May 30 '21 at 09:54
  • 1
    I must admit that was a tricky one... I think I'm going to add ratios along with the %s now... – Nickotine May 30 '21 at 09:55
  • 1
    Or another is people who are surprised that taking 10% off and then adding 10% on does not return you to where you started. – badjohn May 30 '21 at 10:16
  • what’s the best way to go about turning these numbers into ratios and fractions? Well the fractions would be easy I’m just interested if there’s a good trick @badjohn – Nickotine May 31 '21 at 19:42
  • If you want to compare fastest to slowest then the ratio is just $\frac{time_{slowest}}{time_{fastest}}$. For percentage faster, use $percentage = (ratio - 1) \times 100$. – badjohn May 31 '21 at 20:22
  • what I done was just convert the %s to fractions @badjohn, I'll post the results in my question, could you take a look? I'm really quite nervous with my maths – Nickotine May 31 '21 at 21:16