Jose Sandoval Google
 Resume     Book     Software     Drawings     Home     Subscribe to RSS feed Search Web Search

Histogram Calculator - A Java Applet
Friday, April 29, 2005

A wise man once said:
    Oh, people can come up with statistics to prove anything. 14% of people know that.

    Homer Simpson
Statistics is one of the misunderstood fields of Mathematics. In the wrong hands it can be used to lie and manipulate and most of the time to wrongly predict sunny skies: "...30% chance of rain..." Sure.

The true value of statistics is in the power of prediction and analysis of any type of phenomena. I.e. By measuring the results of a process many times over we can generate graphs from the recorded data and we can calculate averages and standard deviations to make generalizations about the process.

Histograms are like frequency charts, but different. I.e. The 'y' axis is really the percentage of a certain event occurring in a set of observed events. The big secret: divide the frequency by the total number of elements to get the relative frequency :)

Anyway, the Histogram Calculator accepts a set of data - numbers separated by spaces, tabs, or 'enters' - And when you click the "Draw Histogram" button a histogram from the data given is drawn, together with a quick summary of the data. I've also added a plot of the Normal distribution for good measure.

For this Java applet I haven't included the source code (I usually do). I'm too lazy to comment it. But, if you are really eager you can decompile the classes and figure out what's going on.

Another thing to note is that the applet is not 1.0 compliant. You can thank Microsoft for not including a JVM in your IE browser and my laziness for not porting it to be JDK 1.0 compliant. So, in order to see it running you need to have the Java plug-in installed for your browser of choice. Chances are, you already have the Java plug-in installed.

A quick peek at the code
The Normal probability density function is a funky looking formula that can be derived using some funky calculus:

This curve is part of the Gaussian family of curves. Lots of e's and π's in it.

My Java implementation looks like this:
private double getProbability(double z) {
return (1.0 / Math.sqrt(2.0 * Math.PI))
* Math.exp(-0.5 * z * z);
That's straight forward, I think. Now plotting the function is a bit more fun. Java2D doesn't have a Cartesian plane pre-defined, hence you must calculate everything by hand.

Note that getProbability(double z) expects a normalized parameter. This means that the 'z' parameter needs to be of the form: z = (value - mean) / sd.

Go to the Applet...

1:53 AM | 2 comment(s) |

3 degrees to Kevin Bacon
Wednesday, April 20, 2005

There are approximately 6,379,157,361 living humans on earth. A remarkable fact that we are all connected somehow, comes as a shock to some.

We've all heard about "6 degrees of separation," haven't we? And it's hard to imagine that it takes up to 6 "degrees" to be connected to anyone in the world - Anyone - Even Kevin Bacon.

Anything with numbers in it is part of mathematics and this type of "connectedness" is right up Graph Theory's alley. Mathworld has this to say about this type of phenomenon:
    Taking a connected graph or network with a high graph diameter and adding a very small number of edges randomly, the diameter tends to drop drastically. This is known as the small world phenomenon. It is sometimes also know as "six degrees of separation" since, in the social network of the world, any person turns out to be linked to any other person by roughly six connections.

    In modern mathematics, the center of the network of coauthorship is considered to be P. Erdos, resulting in the so-called Erdos number. In movies, Kevin Bacon is often mentioned as the center of the movie universe, but a recent study has shown Christopher Lee (Reynolds) to be the actual center. Both actors have co-starred with Julius LeFlore, so the Lee-Bacon distance is two.
I don't have an Erdos number, as I don't do Mathematical research, however, I do have a Kevin Bacon degree: 3.

I'm connected to Bacon via Kristin Booth, who worked with Paul Brogren in a movie called Detroit Rock City (1999); and Brogren was in Cavedweller (2004) with Kevin Bacon

We are all connected - What's your Bacon degree?

I know (well, I don't really know her nor remember much of her) Kristen from high school - We went to the same high school - I think she was in grade 11 or 12 when I graduated from grade 13 (OAC) and I do recall saying hi to her once or twice. I also remember she was in a few school plays - I don't believe I saw any of them, nor have seen any of her later work.

I don't follow any of the Hollywood silliness, and my point is not to bring to light my Bacon number (It's irrelevant who the other person is), but the connectedness of human beings: we are closer than we think or would like to be.

Silly Facts
  • Booth's name is actually Kristen, however, I've seen her name misspelled all the time as Kristin. I think she gave up and she now goes with Kristin - I don't know anything about marketing actors, however, it has to be frustrating correcting executives who probably ask: "Who is Kristen Booth?"

  • An interesting fact about Graph Theory is that is has been categorized in the field of Operations Research and Combinatorics and Optimization - Well, that's not the interesting part - The interesting part is that most of the research on OR came about from the need of our advanced societies to wage war, more effectively and efficiently, against each other. I.e. During WWII British and US researchers "looked for ways to make better decisions in such areas as logistics and training schedules."

  • Most military research makes its way into the everyday life: ARPANET, Satellite TV, RSA, 4x4s, swiss army knifes - I'm sure I missed some.

  • A popular book that is "claimed" to have something to do with this area of "connectedness" is The Tipping Point: How Little Things Can Make a Big Difference - It doesn't. I bought the book as the subject sounds interesting and it has been going around the bloggosphere. I don't recommend it - It's a dummyfied collection of newspaper articles (it feels that way) of anecdotes and musings about a couple examples where something became a fad overnight (Shoes, for example) - It doesn't actually dissect how "it" became a fad or what made it tip, is just goes back in time and tells you what it was - Hindsight is 20/20, after all.

    11:38 PM | 1 comment(s) |

    Education with a warranty...
    Wednesday, April 13, 2005

    You rarely see anything with a life time warranty, unless the product is really good or the company is going out of business very soon.
      Lifetime Warranty
      As a present or former student, you have the right, always and forever, to come and see me, to call me, to e-mail me, to talk to me, to ask for letters of recommendation, to ask questions -- about your courses, your degree, your future schooling, your career, your life; I will never be "too busy" to see you.

    I can't claim to have been his student, but what an interesting concept.

    8:37 AM | 0 comment(s) |

    Google maps uncovers Area 51...
    Monday, April 11, 2005

    So much for not being "officialy" there: Area 51.

    Other interesting places.

    9:25 PM | 1 comment(s) |

    DAO + my DBUtil + Struts 1.2
    Sunday, April 03, 2005

    DBUtil is my freely available database utility based on the Jakarta commons-dbutils. It also includes a database connection pool, which is easily configurable via a file.

    Running Application and Source Code
    You can think of the application I provide in the tutorial as a canonical example of a Struts application + my DAO-like pattern and DBUtil + a working example of and app using Jakarta commons packages.

    You can find online:My DBUtil + Modified DAO Pattern
    The approach I describe is DAO-like in the sense that your database interactions are delegated away from your controller classes or business objects to DBUtil.

    Your Action and BO classes don't know nor care how the persistence layer is implemented. More over, the code you need to interact with the database is minimal.

    For example, this is what a method to create a new record looks like:

    public static void create(DemoVO vo) throws Exception {
    new Object[] {vo.getName(), vo.getLastName()});

    Perhaps someone out there can make use of it - It defenetely has saved me countless hours of coding in the last couple of years.

    4:39 PM | 2 comment(s) |

    New OO language Yava, from Zun
    Friday, April 01, 2005

    For immediate release.

    Today, I've started a brand new company called Zun Inc.

    This company will be the corporate head quarters of the new OO language called Yava (TM).

    It's very similar to Java (from Sun), but yet different and much better. Yava uses most of the Java APIs from Sun (OO is about code reuse), but most (if not all) of the packages will be called com.zun.etc.etc. and the java.* packages are renamed to yava.* - There will be less confusion that way.

    The language is so good, that I already started on a Y2EE version that supports Yava servlets and YSP pages - There is one difference with Yava: you'll have to pay to use it - None of that free (as in beer) stuff like Java - I'm running a business, here.

    Where did I get the money?
    Finally, my contact from Africa came through and deposited the $100,000,000.00 from a surplus of some oil company that he just happened to be the legal counsil for and, conviniently enough, the CEO got bitten by bees infected with rabies. I don't ask too many questions - Bees with rabies?

    Who would have thunk it, those stupid spam letters do work.

    To be on the safe side and to make sure my investment is well guarded, I'm hiring the Ex-Enron CEO as my CEO and Martha Stewart as my investing advisor.

    BTW, I'm hiring. In order to qualify you must send your resume together with a list of your top 1000 weaknesses. I'll accpet 999, but 1000 would be considered an asset.

    BTW2, I found through my lawyers that Java's mascot name is Duke. Man, I like that name. Oh well, I had to settle for a more copyright-friendly name and more original I thought. Hence, Yava's mascot name is Puke.

    7:30 AM | 1 comment(s) |

    This page is powered by Blogger. Isn't yours?

  • Guestbook
    © Jose Sandoval 2004-2009