Skip to content

Instantly share code, notes, and snippets.

@DRMacIver
Created July 6, 2022 09:57
Show Gist options
  • Save DRMacIver/b1df3270938b9ad2e1e46c11fa62d055 to your computer and use it in GitHub Desktop.
Save DRMacIver/b1df3270938b9ad2e1e46c11fa62d055 to your computer and use it in GitHub Desktop.

How to pick a number

One decision we often find ourselves having to make is that we have to put a number on something.

For example:

  • How much should I pay for e.g. a computer/car/house?
  • How much time per week should I spend e.g. cleaning/reading/working?
  • How long do I expect this task to take?
  • Roughly how large is this unknown quantity? e.g. how many people would be interested in a product, how large should a company be, how many boxes do I need to move?

There is a procedure that works quite well for this, which is to use a variant of what programmers call a binary search.

It works as follows:

  1. Pick a number that is definitely too low (a lower bound), and a number that is definitely too high (an upper bound).
  2. Tighten your bounds by repeating the following procedure:
    1. Consider some nice number in between the two (a guess) and ask whether tha number is too low or too high.
    2. If it's too low, it's your new lower bound.
    3. If it's too high, it's your new upper bound.
    4. If you're not sure, try again with a different guess.
    5. Stop when you can't come up with any reasonable guesses that you're sure about.
  3. If your bounds are still very far apart, such that there's a huge difference in outcome from picking the lower and upper bound, you need to learn more. Try to come up with some experiments to run, or questions to ask, or otherwise think hard about the problem.
  4. If your bounds are quite close, now make a discrete decision between your lower bound, your upper bound, and some nice midpoint as follows:
    1. If it's much worse to choose too low, pick the upper bound.
    2. If it's much worse to choose too high, pick the lower bound.
    3. If choosing too high or too low is equally bad, pick a number roughly in the middle.

Let's consider a worked example. I'm at the time of writing this trying to decide what the maximum rent I'm willing to pay on a new home is. Obviously the amount I'm willing to pay for any given flat depends on the flat, but I need to know the upper bound to see alerts on properties and to not waste my time on anything that is obviously out of my price range.

First I pick a lower bound. I've looked at the flats in the area, and there are some available for about £600 / month, but they're all terrible and I would regret moving into them if there were a nicer place available for a bit more money. So let's pick £500 as our lower bound - I'm definitely willing to pay more than £500.

Now I pick an upper bound. I'm currently paying £1350/month in rent, and I would be upset if that number went up by a lot, but also I would be upset if say there were a gorgeous place available for £1400 and I didn't snap it up. So clearly my maximum is a bit above that. Let's pick £2000 as obviously too high (it's in fact well above what I can really afford to pay).

So now I want to narrow these bounds, and pick a nice round number in the middle, £1000.^[Note that this is not what a conventional binary search would pick, which would be the exact midpoint of £1250. The point is to pick nice numbers so it's easy to reason about.]

£1000 seems still obviously too low, in that if a good place came up for £1000 I certainly wouldn't turn it down. So now our lower bound is £1000.

Picking a nice round number between our lower bound (£1000) and our upper bound (£2000), I get £1500. Is this too high? i.e. would I in principle be willing to pay £1500 for a place? Well... maybe. If it were an absolutely amazing place I'd have to think really hard about whether I was willing to pay that much. I certainly wouldn't be willing to pay more. So let's put that as our new upper bound.

Now let's pick a non-round number between the two which is nevertheless easy to reason about: £1350, my current rent. Am I willing to keep paying my current rent? Yes, I guess so. Certainly I can afford it, and I'd be entirely up for paying that if I got a much better place than I currently have.^[We could reasonably have started here, but actually I was less sure of this at the beginning of the process - one of the appeals of where I'm moving is that it's cheaper. Thinking about the numbers in more detail made this clearer.]

Now, my range is looking pretty narrow: There's only £150 difference between the upper and lower bound, and I don't have much intuition about the difference between these. I could try to narrow it further, but it doesn't seem worth it.

Now, do I want to err on the side of picking a number that is too low, or a number that is too high? Because the purpose here is not to make a final decision on rent, and instead to just filter down the flats to ones I might consider, it seems much worse to pick too low than too high. If I tend up getting absolutely bombarded with flats costing £1500 that I don't want, I might have to adjust, but for the moment it seems like erring on the side of too high is by far the better choice. So I pick £1500 as my maximum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment