Live data from Hacker News

The Lost Art of Logarithms

lostartoflogarithms.com

21–30 of 204 posts

Re: The Lost Art of Logarithms

#21

Notation for writing log has always bugged me. Like I feel like it should be more like ^ which would be the log base 10 of 527. That's not it, but something. The current notation just doesn't feel quite right.

https://mathcenter.oxford.emory.edu/site/math108/logs/ Some people have suggested the "triangle of power".

I think it's good for explanation purposes, but not actually great as notation, especially for operations that are so common, too much room for ambiguity, especially when writing quickly.

Re: The Lost Art of Logarithms

#22
post #2

I started using LMAX Disruptor for some projects. One quirk with Disruptor is that the queue size always has to be an exponent of two. I wanted to make sure that I always have at least enough room for any size and I didn't want to manually compute, so I wrote this: var actualSize = Double.valueOf(Math.pow(2, Math.ceil(Math.log(approxSize) / Math.log(2)))).intValue(); A bit much for a single line, but just using some…

This is perfectly usable, of course, but I’d write var actualSize = Integer.highestOneBit(approxSize - 1) purely to avoid involving the horrors that live beneath the humble pow() and log(). (Integer.highestOneBit, also known as “isolate leftmost bit”, “most significant one”, or the like, essentially has to be a primitive to be efficient, unlike its counterpart for the lowest bit, x&-x. The actual CPU instruction is u…

shouldn't it be

var actualSize = 1 ?

Re: The Lost Art of Logarithms

#23
post #18
post #13

Earlier quoted context omitted.

Yes the office door stop as it was known as at our place. Top book though just faded in utility and no one had the heart to dispose of it because of the good memories.

Good book indeed, just that I wouldn't use a book to look up Win32 API functions.

It used to be the only way!

Re: The Lost Art of Logarithms

#24

Here's an logarithmic fact that I've made use of frequently: If X is a random variable having a uniform distribution between zero and one, then –ln( X )/ λ has an exponential distribution with rate λ . This relationship comes in handy when, for example, you want to draw weighted random samples. Or generating event times for simulations.

How long do I have to study math to understand this?

Re: The Lost Art of Logarithms

#25

Earlier quoted context omitted.

This is perfectly usable, of course, but I’d write var actualSize = Integer.highestOneBit(approxSize - 1) purely to avoid involving the horrors that live beneath the humble pow() and log(). (Integer.highestOneBit, also known as “isolate leftmost bit”, “most significant one”, or the like, essentially has to be a primitive to be efficient, unlike its counterpart for the lowest bit, x&-x. The actual CPU instruction is u…

shouldn't it be var actualSize = 1 ?

Nope. I don’t know why the Java folks decided not to use the fairly standard verb “isolate” for this method, but that’s what it is[1]:

> public static int highestOneBit(int i)

> Returns an int value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in the specified int value. Returns zero if the specified value has no one-bits in its two's complement binary representation, that is, if it is equal to zero.

There isn’t a straight floor(log2(·)) as far as I can tell, only Integer.numberOfLeadingZeros, and turning the former into the latter is annoying enough[2] that I wouldn’t prefer it here.

[1] https://docs.oracle.com/javase/8/docs/api/java/lang/Integer....

[2] https://docs.oracle.com/javase/8/docs/api/java/lang/Integer....

Re: The Lost Art of Logarithms

#26
post #24

Here's an logarithmic fact that I've made use of frequently: If X is a random variable having a uniform distribution between zero and one, then –ln( X )/ λ has an exponential distribution with rate λ . This relationship comes in handy when, for example, you want to draw weighted random samples. Or generating event times for simulations.

How long do I have to study math to understand this?

to understand what they said, or to understand a proof of why it would be true?

any stats class would be enough to understand what they said

Re: The Lost Art of Logarithms

#27
post #24

Here's an logarithmic fact that I've made use of frequently: If X is a random variable having a uniform distribution between zero and one, then –ln( X )/ λ has an exponential distribution with rate λ . This relationship comes in handy when, for example, you want to draw weighted random samples. Or generating event times for simulations.

How long do I have to study math to understand this?

Depends where you're starting from but from highschoolish maths you can probably sort this out in a few hours or days.

Re: The Lost Art of Logarithms

#28
There used to be practical value to be able to do some basic back of the envelope log calculations in your head (no calculators, this was how you did fast multiplications/divisions or exponents). There's a story in Feyman's Surely you're joking book about Los Alamos scientists doing speed competitions for mental log calculations

Re: The Lost Art of Logarithms

#29
post #24

Here's an logarithmic fact that I've made use of frequently: If X is a random variable having a uniform distribution between zero and one, then –ln( X )/ λ has an exponential distribution with rate λ . This relationship comes in handy when, for example, you want to draw weighted random samples. Or generating event times for simulations.

How long do I have to study math to understand this?

[deleted]

Re: The Lost Art of Logarithms

#30
post #24

Here's an logarithmic fact that I've made use of frequently: If X is a random variable having a uniform distribution between zero and one, then –ln( X )/ λ has an exponential distribution with rate λ . This relationship comes in handy when, for example, you want to draw weighted random samples. Or generating event times for simulations.

How long do I have to study math to understand this?

I love that you asked this, but I think it's not quite the right question.

I've been wishing for years that someone would maintain a "dependency graph" for mathematical concepts. I think Khan Academy tried to do something like this at one point but took it down a long time ago. As long as we're far enough from the bleeding-edge of research topics, I feel like maths is the one field where this might be possible to do really well. You should be able to point at something you don't understand and trace backwards in a very granular fashion until you hit a concept you already know/understand, and then learn what you need to fill in the gap!

Post reply on HN