Blog

  • Word frequency analysis and Justin Bieber

    Word frequency analysis and Justin Bieber

    Pre-teen girls like Justin Bieber. I get that. Some music executive saw an opportunity for a new franchise and leapt on it. What’s rather unfortunate is that his fans also extend to the listeners of commercial radio.

    I’m pretty tolerant when it comes to standing pop music. But even I have my limits. I had to walk out of a store today because they were playing his song “Baby.” How bad is it? Well, let’s do a bit of word frequency analysis.

    The lyrics of the song consist of 280 words. Out of those:

    • 56 (20%) are the word “baby
    • 21 (7.5%) are the word “yeah

    One out of every five words is “baby”. From a 15 year old kid. Being aired all throughout your shopping experience. Fun.

  • Rice Tea Movie

    Rice Tea Movie

    Alright, so I’m a little behind on the script writing. This is a busy week, so we’ll see how much progress I achieve come next Sunday.

    Like Docks, I’m striving to only write the script in a manner that I know can be shot. There are no explosions, etc. Unlike Docks, however, I don’t have outright access to the sets. With Docks, I worked out a deal to have access to the boats, kiosks, etc. that I needed. Everything I needed was right there.

    With Rice Tea, things are a little different. I’ll need to work out deals with tons of different places, and that won’t be easy. Eh well – that’s what all of May and June will be for. You can download the script in its current form below.

    Downloads:

    Script, March 21 2010

  • Walmart & Accusations of Shoplifting

    Walmart & Accusations of Shoplifting

    Today my boyfriend and I went out to Walmart so that he could refill a prescription. It was a pretty warm day as far as the weather in March goes, so my significant other wore shorts. He also brought some jeans in his backpack just in case the temperature dropped.

    The Walmart we went to is about an hour away by bus. Sure enough, when we get there, the wind picks up. So my boyfriend goes into the washroom to change into his warmer clothes while I go get some supplies. On my way back to the store’s pharmacy, I see a girl in the main aisle with a shirt that says “Security.” She’s talking to a man in shirt and tie, presumably some manager, and I overhear her say “It’s the one with the belt and the backpack – but she didn’t see him do it.”

    I follow the manager as he walks to the prescription counter, where sure enough my boyfriend – studded belt, backpack, and all – is standing. The manager approaches my boyfriend and asks him if he was filling a prescription, to which my mate replied that he was. The manager talks to the girl behind the desk, and leaves.

    Ten minutes later, the prescription is ready. The pharmacist calls out my boyfriend’s name. The girl at the desk runs back, hushes something in her ear, and comes back to us informing us that it’ll be another five minutes. Minutes pass. She gets a call – and informs us again that it will be another five minutes. Finally, half an hour later, she receives a call that gives her the go ahead: she calls out his name, and gives him the bag with $200 worth of meds.

    Jay had been accused of shoplifting the Old Navy pants he was wearing. That much we know. We presume that the delay was the security person reviewing the footage, seeing if he had in fact picked up anything.

    This delay caused us to miss our bus back, which was rather frustrating. As a “fuck you” to Walmart, we shopped around at other stores, and then came back to eat at their own McDonald’s.

  • Why Math is Important for Programmers

    I was talking to someone the other day on IRC, and they were talking about how he saw his math class as being a waste of time. Too theoretical, not practical. It’s usually hard to see the benefits, until you realize that it opens up opportunities on how to solve problems.

    Take today: I wanted to calculate Pi to a certain number of digits. However, I didn’t know how much computer storage, say, a trillion-digit long number would require. Math to the rescue!

    We know that with one bit of computer storage, we can store a one or a zero. With each additional bit of computer space, the biggest size that that stored number can be doubles. For instance, with three bits you can represent all the numbers from zero up to (but not including) eight, but with four, you can represent all the numbers from zero up to (but not including) sixteen. Thus you can use this formula:

    Where maxval is the biggest number you can store given a number of bits. That maximum value is a decimal number. Keep in mind that all decimal numbers can be represented in the scientific notation:

    Where b corresponds to the length in digits of that number. So maxval, in fact, also equates to the following:

    We’re looking for the number of digits in multiple of tens – and therefore a will always equate to being 1. As such, we can simplify the above formula to:

    And thus, since both the first formula and this last one equal to the same thing, we can stipulate the following:

    Since we want to find out the amount of bits given a known number of digits, we need to rewrite the formula so that we end up with the amount of bits. This is where this rule from high school math comes in handy:

    is the same as

    And using that rule, we can rewrite the formula to figure out the amount of bits as such:

    We could stop there. Given the length of a number in digits, we could figure out how many bits would be required to store it. That said, many calculators don’t have the ability to make calculations with logs at base 2. Most calculators are able to however calculate logs at base 10. This is where another high school trick to change bases of logarithms comes in handy:

    Which is applied to our formula to convert it to the following:

    Finally, the above can be simplified. Keep in mind that:

    So the logarithm in the top portion of the equation actually equals digits in itself:

    Keeping this in mind, the whole formula can be rewritten as such:

    And since a logarithm without an indicated base is assumed to have base 10, the above formula can be further cut down:

    And that’s it! Thanks to a little bit of math, we can figure out how many bits of space would be required to store a certain amount of digits. So, going back to the pi example – how much storage space would be required to store pi to a trillion digits?

    Storing pi to one trillion digits would require approximately 3.3 trillion bits of computer storage, or around 387 gigabytes! Problems like the one exemplified here aren’t uncommon, and a solid foundation in mathematics can go a long ways in opening new doors as to how to solve them.

    So whether you’re taking calculus, linear algebra, numerical analysis and/or statistics – remember: that theory you’re learning will come in handy one day.

  • …then again

    Finding a significant other does have a way of reinvigorating yourself. (See previous post.)