~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Animated Arithmetic / 4 months ago
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

I finished moving my old Animated Arithmetic pages into the new Sandbox site. In case anybody was interested.

--------------------
:::Comments:::

(New comment)
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Factors and Terms / 4 months ago
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

I got to have more fun playing with Treetop and context-free grammars today by creating a new Sandbox item that decorates algebraic expressions with boxes indicating factors and terms. As I've found myself doing a bit of algebra tutoring lately, it might be helpful.

--------------------
:::Comments:::

(New comment)
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Birthdays / 4 months ago
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

Several times now I’ve been in a classroom situation where the professor has mentioned the well-known birthday paradox, and had the time and people to perform a demonstrative experiment, but didn’t seem as interested as I was. This morning I realized I could perform the experiment on my own without having to bother anybody else thanks to the magic of Facebook profiles. Since most people have their birthdays listed, I just opened up my list of friends alphabetically and starting listing birthdays to see how long it would take before one of them repeated:

  1. Feb 2
  2. Nov 26
  3. Mar 29
  4. Mar 14
  5. Aug 27
  6. Sep 30
  7. Jul 6
  8. Nov 24
  9. Jun 3
  10. May 8
  11. Apr 23
  12. Apr 20
  13. Feb 2

Statistics says that there isn’t a better-than-average chance of a birthday collision until a group has at least 23 people in it. For only 13 people, as we have here, the probability of a collision is only

1 - (365!/352!)/36513 = 19.4%

Everybody try this at home!

--------------------
:::Comments:::

\__________ Rachelle -- 4 months ago __________/
Here's my result: Sep 29 Oct 16 Mar 25 Sep 16 Oct 15 May 6 Dec 15 Nov 9 May 19 Dec 21 Nov 14 Aug 12 Nov 6 Mar 10 Feb 7 Feb 4 Jul 3 May 21 Jul 2 Aug 9 May 15 Mar 10
--------------------
\__________ Me -- 4 months ago __________/
That's a second one under the supposed average. I wonder if the real-life data are skewed by hospitals affecting birth times (e.g., doing births on weekdays whenever they can have some influence on it), making collisions even more likely.
--------------------
\__________ Rachelle -- 4 months ago __________/
Yeah, I read the Wikipedia page, it said that among a group of people born in the same year, some dates are much less likely (like weekends) so that's probably what's happening. Although, a good deal of the people in that group were different ages.
--------------------
(New comment)
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Free $10,000 For Dad / 4 months ago
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

This is just what I need. Why didn’t I think of it before?

I wish I had thought to click on it before it went away. I’ll check it out if I see it again. Should be an exciting experience.

--------------------
:::Comments:::

(New comment)
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
All the Movies / 4 months ago
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

I thought it might be fun to compute the total number of possible movies, based on frame rate, resolution, and the number of possible colors on a standard high-definition digital blu-ray or something. So with some input from people who know more than I do about those things, I came up with the following numbers:

2203 = 10648000 colors/pixel
24 frames/second
1920*1080=2073600 pixels/frame
And I want to calculate all of the possible movies with runnings times less than or equal to exactly four hours.
(4 hours = 14400 sec) * (24 frames/sec) = 345600 frames
Based on the numbers for colors/pixel and pixels/frame, the number of possible frames should be
106480002073600
So for any particular number of frames n, we should have exactly
(106480002073600)n
possible movies. So for all possible movies less than or equal to four hours, we have to sum up these terms for all n from 0 to 345600. According to the appropriate summation formula, this is equal to exactly
(106480002073600)n+1
106480002073600-1
And by plugging in the appropriate value, we get, finally,
(106480002073600)345601 =
106480002073600-1
=
10648000716638233600
106480002073600-1
If we want to use logarithms to estimate the size of this number, we can safely ignore the relatively inconsequential bottom half of the fraction and compute
log10(10648000716638233600) =

716638233600(log1010648000) = 5036008956987
So we're talking about a number that has over five trillion digits. That's so many movies that if you watched a movie every day for the rest of the month, you still wouldn't be done!

--------------------
:::Comments:::

(New comment)
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Ugly Duckling / 4 months ago
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

Don’t these Facebook applications have access to profile information such as gender? These English pronoun misuses shouldn’t be necessary.

And if you’re thinking perhaps the person didn’t actually specify gender in her profile, good guess. But she did.

--------------------
:::Comments:::

(New comment)
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Rails Serialization / 5 months ago
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

This morning I discovered a minor issue with Rails serialization. Any class such as

class Thing < ActiveRecord::Base
  serialize :value
end
uses YAML for serialization, and issues come up if you want to store a String object that happens to have some YAML in it:
>> my_string="---\n:this_should_be_a_string:\n- 1\n- 2\n- 3"
=> "---\n:this_should_be_a_string:\n- 1\n- 2\n- 3"
>> t=Thing.new(:value=>my_string)
=> #<Thing id: nil, value: {:this_should_be_a_string=>[1, 2, 3]}>
I checked the YAML spec and they certainly provide for this (as expected in any serious markup language), using escaped double-quotes. Things get really weird when I try to store a string representing the YAML escaped-double-quoted representation of the above string:
>> t=Thing.new(:value=>"---\n\"#{my_string.gsub("\n","\\n")}\"")
=> #<Thing id: nil, value: "---\n:this_should_be_a_string:\n- 1\n- 
2\n- 3">
>> t.value
=> {:this_should_be_a_string=>[1, 2, 3]}
>> t
=> #<Thing id: nil, value: {:this_should_be_a_string=>[1, 2, 3]}>
I check the rails source and couldn't find anything about YAML anywhere (though several instances of JSON and XML). So I don't know what's going on. I doubt this problem would come up much, but it still surprised me.

--------------------
:::Comments:::

(New comment)
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Website Rearranged / 5 months ago
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

I've rearranged my website. Aside from my blog, there is a Sandbox area where I'm grouping my programming projects and web applications. I had an old original section, but I'm phasing that out now.

I've also finished a new interactive Polynomial Enumerator for the Sandbox. It's based on something I tried on my old site, but never made into anything user-friendly until now. If you like silly visual math things like I do, try it out. It falls into the category of playing-around-with-infinite-things. There's also an accessible explanation for people who don't regularly dream about set theory.

--------------------
:::Comments:::

(New comment)
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
C++ Upsets Me / 5 months ago
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

I promise $25 to the first person who can explain to me what the difference here is:

error: no matching function for call to `Station::setStationAnimationID(int)’ note: candidates are: void Station::setStationAnimationID(int&)

SCREAMING!!!!

--------------------
:::Comments:::

\__________ Patrick -- 2 months ago __________/
int& is a pointer to a memory location. int is a variable. If it's expecting a memory address 0xff0044 or whatever, and instead it gets the value in that location, it will give you an error (if you're lucky) or simply malfunction when executed.
--------------------
\__________ Me -- 2 months ago __________/
Then what's the difference between that (int&) and an explicit pointer (e.g., void Station::setStationAnimationID(int*))? I understand the pass-by-reference/pass-by-value distinction for objects, but I can't see that it's a useful distinction for primitives, and I don't know why that would effect the caller either.
--------------------
(New comment)
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Math Joke / 5 months ago
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

I was taught undergraduate discrete math by Dr. László Székely, who taught it in a very dry, robotic way; he may as well have been reciting a graduate-level textbook. As far as I remember, he told about two jokes the entire semester. One of them was my favorite moment in that class, but nobody else seemed to think it was funny, or even recognize it as a joke.

He was working with a particular limit, and apparently the relevant behavior we were looking for was whether or not it converged to zero as it approached infinity. He showed with some algebra or something that the function was simply the constant one, “…and one does not go to zero as far as we know.”

--------------------
:::Comments:::

\__________ Rachelle -- 5 months ago __________/
Sorry Gary, I don't get it either.
--------------------
\__________ JasonRikard -- 18 days ago __________/
haha, love it.
--------------------
(New comment)
====================================================================================================