Monthly Archives: November 2008

Guitar Tabs for Android Kikaider: The Animation

1
Filed under Uncategorized

I couldn’t seem to find any decent tabs for the songs Jiro plays in Android Kikaider: The Animation (an anime that used to play on Adult Swim a few years ago), so I made up my own.
Disclaimer: The following is my own interpretation, not to be sold, don’t sue me etc.

Jiro’s Theme

————————-5—————————————-
———6—–5—–6——-6———–6—–5—–6————
———7—–7—–7——————-7—–7—–7————
—–7——————————-7—————————-
-5———–5—–5————-5———–5—–5————–
——————————————————————

Theme of Gemini

—–11—10—–11————-11—10—–8————————–
-8——————8——-8—————–11—–9————–8–
———————————————————–8—10——
———————————————————————–
———————————————————————–
———————————————————————–

—–11—10—–11————-11—10—–8——————-8——
-8——————8——-8—————–11—–9—–11——-8–
———————————————————————–
———————————————————————–
———————————————————————–
———————————————————————–

———————————————————————–
-8—8h9—8————–11———————11———-8h9——-
—————10—8——–10——-10—8——–10—————–
———————————————————————–
———————————————————————–
———————————————————————–

—————-8——-8—8/9—9—————-8/9—9————-
-8—9—9h11—————————9———————-9——-
——————————————10———————10—-
———————————————————————–
———————————————————————–
———————————————————————–

———————————————————————–
——9—9/11——-11—11h13—–11-10——————————
-11——————————————————————–
———————————————————————–
———————————————————————–
———————————————————————–

—–11—10—–11————-11—10—–8————————–
-8——————8——-8—————–11—–9————–8–
———————————————————–8—10——
———————————————————————–
———————————————————————–
———————————————————————–

—–11—10—–11————-10h11—10—–8——————-8—–
-8——————8——-8——————–11—–9—–11——-8-
————————————————————————-
————————————————————————-
————————————————————————-
————————————————————————-

—–11—10—–11————-10h11—10/11—
-8——————8——-9——————-
————————————————
————————————————
————————————————
————————————————

–8-9—–9—9/11—11/13-
—————————
—————————
—————————
—————————
—————————

An Interesting Random Number Problem

1
Filed under Uncategorized

In Systems Security class, the professor presented us with an interesting homework problem involving random numbers which I thought some of you might enjoy.

To begin with, a perfect random number generator is a mythical device which spits out bits of either 0 or 1 completely randomly, with a 50% chance of spitting out either a 0 or a 1 at any time regardless of what bits it’s output in the past. Of course, such a generator is impossible to create in deterministic machines (computers), so programmers use pseudo-random number generators instead.

Now, the problem: Assume you have a biased-random number generator – that is, you have a magical random number generator which is completely non-deterministic, but the probability of outputting one bit-state is higher than the other. For example, it could output a "1" with 60% probability and a "0" with 40% probability, or perhaps output a "1" with 0.01% probability and a "0" with 99.99% probability. The only thing known about the probability of outputting a 0/1 is that it’s fixed and greater than 0%.
Given only a computer which can read bits from this biased-random number generator, can you create a perfect random number generator? (and if so, how?)

Java BigInteger Benchmarks

2
Filed under Uncategorized

According to this page (near the bottom), when Java 1.3 switched from using a native BigInteger implementation to a purely-Java implementation, it gained an increase in speed of "as much as 5x or more." This has led many people to believe that Java’s BigInteger class is comparable in speed to the popular Bignum and GMP C-libraries.

I recently got to work with both BigInteger and Bignum for a project implementing a signing scheme related to RSA, so I decided to go a bit out of my way and compare the speeds of each on my machine. In addition, I needed a list of the first 16-million odd prime-numbers, so I implemented a simple Sieve (pronounced "siv," not "seeve") in both Java and C, with some surprising benchmarks.

The Setup
I used the current latest versions of the Java runtime (1.6.0.07) and OpenSSL (0.9.8i) in conducting these tests. They were run on an HP Pavilion dv9720us laptop with a dual-core Turion64 TL-60 (2 GHz) under Windows XP. Neither program was written to explicitly take advantage of the dual-core setup, and as far as I could tell (observing Windows task-manager), neither of them did.

BigInteger vs Bignum
The following table summarizes the results. Note that when I say small exponentiation, what I mean is a large (1024-bit) base to a small (32-bit) power, with a large modulus.

BigInteger vs. Bignum
(smaller is better)
 BigInteger (Java)Bignum(C)
16-million small multiplies and a large exponentiation62.94 seconds16.42 seconds
2-million small exponentiations1892.92 seconds553.41 seconds

Also, here are some graphs for those of you who can’t stand to read a blog-post with no pictures:
There would be a picture here if you had a decent browserHere too.

Sieve of Eratosthenes
Perhaps the previous results should have been expected; after all, Bignum is written mostly in pure assembly, and I’m sure there’s some crazy assembly voodoo that can dramatically increase the speed of adding and multiplying large numbers. However, surely with all the amazing advancements in JIT technology I hear about so often, a plain ol’ prime-number generator in Java will perform almost as fast as, if not faster than (the JIT does, after all, have more information available to it than a normal compiler) its half-brother, C … right?

Sieve of Eratosthenes on 16-million numbers
(smaller is better)
JavaC
30.94 seconds7.80 seconds

And the graph, for those of you who dun’ do numbers so good:

Conclusion
What can I say? Everyone knows that for calculation-intensive tasks, native programs run faster than those that run under a VM – but I believe we’ve all been drastically misled as to the difference in speed between the two. Perhaps you should keep this in mind the next time you’re doing requirements analysis for your next project.