gp7's comments

gp7 | 5 years ago | on: Japanese rules for writing your ABCs are surprisingly strict

A nice example of Japanese stroke order mattering are two of the katakana, ツ and シ. The difference is that the former starts at the top left and the strokes move right, then down and across to the left. The latter starts at the top left and moves down, then up and across to the right. It can be hard to tell what one you are looking at in practice if you don't know this.

I think cursive used to serve the same function, which I basically conjecture from the fact that older people tend to be significantly better at reading cursive than me.

gp7 | 6 years ago | on: How to play the guitar by ear, for mathematicians and physicists (2000) [pdf]

Fun book.

"When mass produced, the cost of self-tuning options will be small compared to the price of a quality piano. You might think that this would put piano tuners out of work but that will not be the case because the number of pianos will increase (because of this book), ..."

That's confidence in the method, right there.

gp7 | 7 years ago | on: Show HN: A minimal FFT code

Sorry, I'm not accusing you of anything. By strided accesses I mean when you access elements of an array sequentially using some step size. Think loops with `i += stride` instead of `i++`. In the wikipedia pseudocode this is done implicitly using the 's' parameter. Notice that, in the version you implemented, you split the input into even and odd parts explicitly; you can achieve the same end by accessing the input array in a certain order as you are performing the mathematical operations. This is what the wikipedia pseudocode does. If you've seen other versions of the FFT with a bit reversal step, this is also where that comes in.

Check this out (javascript):

  function permute1(x) { 
      if (x.length == 1) return x;
      let even = [];
      let odd = []; 
      for (let i = 0; i < x.length; i += 2) { 
           even[i / 2] = x[i];
           odd[i / 2] = x[i + 1];
      }
      return [].concat(permute1(even), permute1(odd));
  }

  function permute2(x, offset, stride) {
      if (!offset) offset = 0;
      if (!stride) stride = 1;
      if (stride >= x.length) return [x[offset]];
      return [].concat(permute2(x, offset, stride * 2), permute2(x, offset + stride, stride * 2));
  }
  
  function permute3(x) {
      let result = [];
      for (let i = 0; i < x.length; i++) {
          let k = i;
          // pretend 32-bit ints
          k = ((k >> 1) & 0x55555555) | ((k & 0x55555555) << 1);
          k = ((k >> 2) & 0x33333333) | ((k & 0x33333333) << 2);
          k = ((k >> 4) & 0x0F0F0F0F) | ((k & 0x0F0F0F0F) << 4);
          k = ((k >> 8) & 0x00FF00FF) | ((k & 0x00FF00FF) << 8);
          k = ( k >> 16             ) | ( k               << 16); 
          k = k >> (64 - Math.log2(x.length));
          if (k < 0) k += x.length; // fix up due to signed ints
          result[i] = x[k];
      }
      return result;
  }
For arrays with power of two sizes, these perform the same permutation (but fail differently for non power of two sizes). Note that, with permute1, we effectively iterate over the entire input log2(n) times, so this is an O(nlogn) algorithm!

edit: also, i think i may have misunderstood the relationship between your js version and your lambdatalk version. They seem to be the same to me?

gp7 | 7 years ago | on: Show HN: A minimal FFT code

The code is mostly equivalent to the recursive form found in the wikipedia article on the cooley-tukey algorithm. This is a good one to learn from, as its not only a simple formulation but it forms the basis of modern optimised FFTs such as FFTW (source[1], from the authors of FFTW).

As an aside, I also find the non-recursive, breadth-first, form easy to derive thru a process of code transformations of the depth-first form; explanations that start breadth-first are somewhat bewildering

[1] https://cnx.org/contents/ulXtQbN7@15/Implementing-FFTs-in-Pr...

gp7 | 7 years ago | on: A First Course in Differential Equations for Scientists and Engineers

> 4. Teach Changes of Variables

As someone who has basically no formal training in mathematics outside what's required for undergraduate computer science this is a big one. The first time I saw it I was blown away. Everyone who knows of it seems to treat it as natural as breathing, and not worth the exposition

gp7 | 7 years ago | on: JupyterCon: I don't like Notebooks [slides]

My experience with notebooks matches the one presented here. For me the most disappointing thing is that notebooks are JSON, and not just marked up .pys. The cons of this decision outweighs the pros for me.

One thing though--one of the best books I've read, Trefethen's ATAP, was written as a collection of .m files, which when run would produce a pdf of each chapter. The .m files were filled with small formatting details that were simply omitted from the generated book. The slides suggest something equivalent is not possible with notebooks. That's unfortunate.

gp7 | 7 years ago | on: Using John Varney's rhythm wheel to differentiate 3/4 and 6/8 time signatures

Time signatures are about writing and reading music. A beat being in 3 or 6 is independent from the time signature, which is whatever the transcriber thought best (you can always count a song in 6 in 3.) A piece in 4 might have pervasive use of triplets, so it would make it more readable to notate in 12/8 rather than 4/4, but there is no triplet-pervasiveness threshold for when to prefer one over the other. Likewise, it would be foolish to have the stress in a waltz occur on the 1st and 4th, then 3rd, then 2nd beat of the bar (this happens if you notate one in 4), but any enterprising composer would be able to thwart any rules you cared to come up with to codify that without much effort.

So: the time signature just describes how many times to count within a bar/measure, and what subdivision (that corresponds to a certain notation) you are counting. For communicating to another musician the rhythm of a song you'd just drop the subdivision part, because it's only relevant to notation.

gp7 | 7 years ago | on: A PhD should be about improving society, not chasing academic kudos

Bizarre. This is coming from someone presumably embedded in the grant-writing machine that is modern academia. How do grant proposals justify their cost, exactly? Academia would be healthier if some back slaps at the next conference was all it took I think
page 1