I am a firm believer in life-long learning. I read a great deal, and love learning about new things. One of the best articles I have ever read about education was in an issue of Electronic Design. I reprinted the entire article on my home website: How To Teach Yourself Almost Anything.
The ‘Wisdom Tree’
Education is not just something that we go through in school, it is the life-long process of acquiring new information, and applying it to the situation you find yourself in at the moment.
Some of you may have heard of the ‘Tree of Wisdom’. In our world, there is a great deal of random noise. Out of that noise, data can be found. With enough data, you can cull out information. As the level of information grows, it is gradually converted into knowledge. Eventually, with lots of practice, time, and effort, that knowledge can be applied to a given situation - in a form we call wisdom. Wisdom is the application of large chunks of our knowledge to solve a problem.
What have I learned?
This summer, I have learned both PHP and Java.
PHP is a lot of fun to use. It’s extremely flexible, easy to learn, and powerful. The built-in library is very broad. Learning the basic syntax (its rules of grammar) of the language is straight-forward, especially if you have ever programmed in other languages, which I have, and especially if those languages include shell scripting and C/C++ (I have done both). PHP lends itself well both to web development (it’s primary target arena) and to shell scripting.
The first ‘real’ script I wrote (with help) goes recursively though the top-level directory you hand it, and inserts text at the top and/or bottom of every HTML file in the directory, immediately after the top tag, and then right before the tag at the bottom. Currently, inshf (insert header footer) is a shell script, but I am working on making it operable as a form-fed webpage.
Java, on the other hand, has not been my friend. The concept of a ‘write once, run anywhere’ language is great. So far, though, Java’s attempt at this has not been pretty. I love object-oriented (OO) design and programming. However, because of the complete inability to write anything that is not encapsulated in a class, Java imposes severe restrictions on simple applications. My first exposure to writing real Java code was a few months ago when I updated Garrett’s CrossBeam applet. He had me incorporate drag-drawing and a reset button. The initial version of the applet required that you manually click to set or unset each grid square, and to clear the drawing space required either a refresh on the page, or to manually empty every square.
Needless to say, this was not a fantastic solution, but it did work. I did a lot of reading through Sun’s online documentation to figure out how to incorporate mouse actions into the applet, but I did eventually get it to work. Since then, my Java work has been centered around an applet to simulate stress and strain for WEAVE. However, I have been finding all sorts of ‘weirdities’ in setting up this new applet. During initial design and testing, I have been setting custom background and foreground colors in the various components that make up the applet. However, the colors don’t get set properly until clicking in the applet.
Problems like this are very hard to track down, especially when the Java documentation says I’m doing everything right. So, for now, I am plowing ahead on this front, attempting to gain enough information on the topic to convert into knowledge… and hopefully be able to apply that knowledge to the problems I am facing.
Other stuff
A couple weeks ago, I was able to take the Scientific Programming workshop offered to interns here at Shodor. I learned a lot during the four-day, half-day workshop. Much of what we covered I had seen or even used in the past, but never knew what it was doing, like Newton’s Method, Euler’s Method, and Monte Carlo Approximations.
Dave taught our class, and introduced all 6 of us to Easy Java Simulations. EJS is a fantastic tool created by Francisco Esquembre for quick tests and simulations where you need visualization, but don’t want to spend a lot of time designing and testing the interface. I emailed Mr Esquembre to thank him for his work. I encourage anyone who downloads and uses the package to send him a brief thank-you message. He’s put a huge amount of effort into this package, and I have found EJS extremely useful in just the couple weeks since Dave showed us how to use it.
Dave introduced us to an (extremely simplified) implementation of a Linear Congruential Generator, one of the most basic pseudo-random number generators available. The basic equation we used is: n = ((n*a) +b) %m
. Since the class, I have spent some time on building a ‘good’ PRNG based on the LCG. One of the tricks of making an LCG perform well is to use prime numbers for a
and b
. I found a table of the first 1000 primes on the internet, and on every iteration through the generator, in addition to picking the next number in the pseudo-random sequence, I also replace my a
and b
for the next iteration, effectively starting a new sequence on every iteration. As mentioned elsewhere on this site, I will be posting my improved LCG as soon as I finish testing it. So far, I have found that the relative probability of biasing high or low is even for any starting point when generating numbers 0..100 inclusive.