Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [QUIZ] Fuzzy Time (#99) - Results

Reply
Thread Tools

[QUIZ] Fuzzy Time (#99) - Results

 
 
Gavin Kistner
Guest
Posts: n/a
 
      11-02-2006
Quiz Summary coming 'soon'. Until then:

Following are the results I obtained from running my test script against
everyone's submissions. (I had to fix minor bugs in a few to make them
work.) After that is the (updated) test script.

The script runs a full day of time against the class, advancing the time
uniformly by different numbers of seconds.

For each result, the first line reports whether the class was generally
fast or slow. (The maximum possible variation is 50% fast or slow.)

The second line is the result of recording, each time the fuzzy time
changed, how many minutes ahead or behind the actual time the change
occurred. Ideally, you should see the same percentages spread along the
whole range.

I didn't test Louis Scoras' submission, because it took a (good, but)
different track for displaying the time, so I knew it wouldn't pass any
of my tests.


Loaded suite GavinKistner_1
Started
2 second advance: 3.3% behind, 19.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 1.4% 6.2% 10% 12% 10% 11% 21% 9.7% 17%

6 second advance: 7.0% behind, 11.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0.7% 5.6% 15% 16% 15% 13% 11% 13% 9.7% 2.1%

17 second advance: 11.3% behind, 12.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
2.1% 9.0% 12% 10% 12% 8.3% 13% 11% 7.6% 5.5% 9.0%

30 second advance: 12.8% behind, 12.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
5.5% 13% 13% 7.6% 11% 9.0% 10% 10% 6.9% 9.7% 3.4%

47 second advance: 14.2% behind, 11.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
7.6% 14% 11% 11% 10% 12% 6.2% 10% 5.5% 5.5% 5.5%

60 second advance: 10.7% behind, 16.0% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
5.6% 9.7% 6.9% 13% 14% 9.0% 6.3% 5.6% 11% 5.6% 13%

65 second advance: 12.1% behind, 16.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
11% 9.0% 12% 7.6% 6.3% 6.9% 6.3% 13% 11% 9.0% 6.9%

120 second advance: 17.1% behind, 11.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 19% 0% 19% 0% 19% 0% 15% 0% 12% 0%

290 second advance: 16.1% behind, 19.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
7.6% 6.9% 6.2% 3.4% 7.6% 5.5% 6.2% 6.2% 6.9% 5.5% 6.2%

=3D=3D=3D=3D=3D=3D=3D

BenGiddings_1.rb
<Mon Nov 13 16:53:02 -0700 2006> expected but was
<Mon Nov 13 16:53:00 -0700 2006>.

It is 07:45, the clock displayed "07:3~",
but it should only display one of ["07:4~", "07:5~"].
(Last time I asked, it said it was 07:3~.)

=3D=3D=3D=3D=3D=3D=3D

Loaded suite CameronPope_1
Started
2 second advance: 0.0% behind, 38.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 0% 0% 0% 0.7% 0% 9.6% 48% 40%

6 second advance: 0.0% behind, 31.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 0% 0% 0.7% 12% 32% 36% 18%

17 second advance: 1.4% behind, 19.0% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 4.1% 2.1% 9.6% 18% 19% 25% 16% 4.1%

30 second advance: 3.9% behind, 14.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 0.7% 7.6% 2.8% 8.3% 14% 22% 17% 13% 8.3% 4.8%

47 second advance: 6.9% behind, 12.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
2.1% 4.1% 6.2% 6.2% 19% 16% 12% 12% 8.9% 9.6% 3.4%

60 second advance: 13.0% behind, 9.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
12% 7.5% 8.2% 10% 15% 12% 14% 8.9% 8.9% 2.7% 0.7%

65 second advance: 11.1% behind, 10.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
11% 4.8% 5.5% 17% 6.9% 19% 11% 10% 7.6% 3.4% 1.4%

120 second advance: 18.5% behind, 10.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 15% 0% 22% 0% 19% 0% 18% 0% 5.6% 0%

290 second advance: 26.5% behind, 11.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
15% 9.6% 6.6% 4.4% 2.9% 3.7% 5.1% 3.7% 4.4% 0% 0%
=20
=3D=3D=3D=3D=3D=3D=3D

DamienPetrelli_1
<Thu Nov 09 14:06:28 -0700 2006> expected but was
<Thu Oct 26 01:15:46 -0600 2006>.

It is 02:26, the clock displayed "12:5~",
but it should only display one of ["02:2~", "02:3~"].
(Last time I asked, it said it was .)

=3D=3D=3D=3D=3D=3D=3D

Loaded suite DanielLucraft_1
Started
2 second advance: 8.1% behind, 16.0% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 11% 7.6% 9.7% 13% 11% 9.7% 9.7% 9.0% 8.3% 10%

6 second advance: 7.6% behind, 18.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 9.7% 9.7% 8.3% 6.9% 9.0% 12% 8.3% 12% 12% 11%

17 second advance: 9.3% behind, 15.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 12% 11% 9.0% 9.0% 8.3% 14% 9.7% 7.6% 9.0% 9.7%

30 second advance: 7.8% behind, 16.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 8.3% 12% 6.9% 12% 9.0% 12% 10% 9.0% 10% 9.0%

47 second advance: 8.6% behind, 14.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 10% 8.9% 6.2% 12% 14% 10% 10% 7.5% 12% 7.5%

60 second advance: 6.7% behind, 19.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 8.3% 9.0% 7.6% 6.3% 9.0% 11% 14% 10% 13% 12%

65 second advance: 8.8% behind, 16.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 8.3% 12% 12% 12% 11% 7.6% 6.2% 9.0% 6.9% 13%

120 second advance: 6.9% behind, 20.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
10% 0% 16% 0% 18% 0% 21% 0% 23% 0% 11%

290 second advance: 7.0% behind, 16.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
7.3% 9.5% 14% 12% 8.0% 12% 10% 4.4% 7.3% 4.4% 2.9%

=3D=3D=3D=3D=3D=3D=3D

Loaded suite JeremyHinegardner_1
Started
2 second advance: 0.0% behind, 42.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 0% 0% 0% 0.7% 20% 78%

6 second advance: 0.0% behind, 38.3% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 0% 1.4% 9.7% 51% 37%

17 second advance: 0.0% behind, 31.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 2.1% 0.7% 17% 29% 30% 21%

30 second advance: 0.0% behind, 29.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 0% 1.4% 8.3% 17% 32% 26% 15%

47 second advance: 0.8% behind, 20.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 5.5% 13% 19% 21% 21% 12% 7.5%

60 second advance: 0.8% behind, 24.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0.7% 0.7% 2.8% 4.1% 7.6% 14% 19% 23% 21% 6.9%

65 second advance: 1.5% behind, 21.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0.7% 1.4% 2.8% 9.7% 9.0% 17% 17% 21% 16% 5.5%

120 second advance: 6.9% behind, 10.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 10% 0% 17% 0% 34% 0% 30% 0% 7.6% 0%

290 second advance: 8.4% behind, 13.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
9.2% 11% 12% 11% 13% 11% 7.7% 6.3% 7.0% 4.2% 0%

=3D=3D=3D=3D=3D=3D=3D

Loaded suite MarcelWard_1
Started
2 second advance: 7.2% behind, 17.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 6.2% 6.8% 8.2% 7.5% 11% 4.1% 17% 14% 14% 11%

6 second advance: 5.4% behind, 18.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 4.2% 4.9% 6.9% 7.6% 10% 12% 16% 15% 9.0% 14%

17 second advance: 8.1% behind, 15.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 8.2% 6.2% 4.8% 11% 16% 12% 8.2% 14% 10% 9.6%

30 second advance: 7.2% behind, 13.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 6.9% 5.5% 7.6% 14% 11% 12% 18% 9.0% 10% 4.1%

47 second advance: 7.5% behind, 16.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 6.2% 9.0% 7.6% 12% 10% 9.0% 15% 12% 12% 6.2%

60 second advance: 10.6% behind, 13.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
4.1% 10% 9.7% 9.0% 13% 8.3% 12% 12% 7.6% 9.7% 4.1%

65 second advance: 7.7% behind, 17.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
4.8% 4.8% 9.7% 7.6% 6.9% 9.0% 9.7% 13% 16% 12% 6.2%

120 second advance: 6.4% behind, 14.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
14% 0% 14% 0% 29% 0% 26% 0% 17% 0% 1.4%

290 second advance: 10.1% behind, 16.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
8.4% 9.8% 9.8% 12% 7.7% 9.1% 10% 10% 4.2% 4.9% 0.7%

=3D=3D=3D=3D=3D=3D=3D

Loaded suite PaoloNegri_1
Started
2 second advance: 7.8% behind, 9.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 5.5% 8.3% 8.3% 17% 17% 18% 10% 10% 5.5% 0.7%

6 second advance: 7.0% behind, 11.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 2.8% 6.2% 10% 12% 17% 12% 19% 9.0% 9.0% 3.4%

17 second advance: 8.1% behind, 10.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 2.8% 10% 8.3% 14% 17% 14% 14% 6.9% 8.3% 2.8%

30 second advance: 8.9% behind, 9.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 7.6% 9.0% 11% 14% 14% 18% 10% 8.3% 5.5% 2.1%

47 second advance: 10.2% behind, 10.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 10% 8.3% 9.7% 14% 17% 9.7% 15% 5.5% 6.9% 3.4%

60 second advance: 8.3% behind, 11.3% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 6.2% 12% 13% 11% 11% 16% 16% 8.3% 4.1% 1.4%

65 second advance: 8.6% behind, 10.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
4.8% 5.5% 4.8% 11% 16% 19% 13% 5.5% 12% 4.1% 2.8%

120 second advance: 6.3% behind, 11.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 8.3% 0% 22% 0% 35% 0% 20% 0% 14% 0%

290 second advance: 9.1% behind, 13.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
6.2% 9.0% 11% 10% 14% 11% 9.7% 9.0% 3.4% 2.8% 0.7%

=3D=3D=3D=3D=3D=3D=3D

Loaded suite RobertConn_1
Started
2 second advance: 0.0% behind, 49.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 0% 0% 0% 0% 0% 0% 0% 99%

6 second advance: 0.0% behind, 48.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 0% 0% 0% 0% 99%

17 second advance: 0.0% behind, 46.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 0% 0% 0.7% 9.0% 90%

30 second advance: 0.0% behind, 45.0% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 0% 0% 0% 1.4% 5.5% 18% 74%

47 second advance: 0.0% behind, 42.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 2.1% 2.1% 2.8% 10% 23% 59%

60 second advance: 0.1% behind, 42.3% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 1.4% 0.7% 6.9% 12% 22% 57%

65 second advance: 0.1% behind, 41.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 2.7% 2.7% 8.9% 13% 20% 51%

120 second advance: 3.6% behind, 27.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 2.1% 0% 9.0% 0% 7.6% 0% 21% 0% 59% 0%

290 second advance: 10.4% behind, 29.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
2.3% 5.5% 3.1% 4.7% 3.1% 5.5% 12% 16% 13% 14% 9.4%

=3D=3D=3D=3D=3D=3D=3D

Loaded suite ThomasMueller_1
Started
2 second advance: 0.0% behind, 43.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0% 0% 0% 1.4% 21% 77%

6 second advance: 0.0% behind, 38.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 0% 0% 0% 0.7% 8.3% 46% 44%

17 second advance: 0.1% behind, 28.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 4.1% 21% 37% 23% 13%

30 second advance: 0.4% behind, 25.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 1.4% 0% 1.4% 3.4% 10% 24% 30% 19% 10%

47 second advance: 0.8% behind, 21.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 0.7% 5.5% 9.0% 19% 19% 20% 16% 9.7%

60 second advance: 1.8% behind, 17.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0.7% 1.4% 4.1% 9.7% 15% 19% 17% 23% 9.0% 1.4%

65 second advance: 1.9% behind, 21.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 4.9% 6.9% 12% 17% 15% 20% 18% 5.6%

120 second advance: 1.7% behind, 19.3% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 0% 8.9% 0% 29% 0% 33% 0% 21% 0% 6.2%

290 second advance: 10.4% behind, 12.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
11% 14% 12% 9.3% 11% 9.3% 7.9% 5.7% 5.7% 2.9% 0.7%

=3D=3D=3D=3D=3D=3D=3D

Loaded suite TomPollard_1
Started
2 second advance: 0.0% behind, 46.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 0% 0% 0% 0% 5.5% 94%

6 second advance: 0.0% behind, 42.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 0% 0% 2.7% 35% 61%

17 second advance: 0.0% behind, 35.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 3.5% 6.3% 19% 38% 33%

30 second advance: 0.1% behind, 29.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 0.7% 4.8% 6.2% 22% 21% 25% 19%

47 second advance: 0.4% behind, 24.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 1.4% 3.4% 6.8% 16% 20% 18% 25% 7.5%

60 second advance: 1.5% behind, 23.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 2.1% 0% 2.1% 4.8% 14% 12% 14% 20% 21% 9.7%

65 second advance: 1.1% behind, 22.0% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 0% 0.7% 0.7% 6.9% 14% 16% 21% 19% 14% 7.6%

120 second advance: 5.0% behind, 13.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 6.2% 0% 17% 0% 34% 0% 25% 0% 18% 0%

290 second advance: 7.4% behind, 16.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
8.0% 12% 11% 11% 12% 10% 10% 7.2% 5.8% 3.6% 0.7%

=3D=3D=3D=3D=3D=3D=3D

Loaded suite TomPollard_2
Started
2 second advance: 0.0% behind, 49.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0% 0% 0.7% 0% 0% 99%

6 second advance: 0.0% behind, 48.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 0% 0% 0% 0% 0% 0% 0.7% 99%

17 second advance: 0.0% behind, 46.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 0% 0% 0% 2.1% 15% 82%

30 second advance: 0.0% behind, 40.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 0.7% 3.4% 3.4% 14% 24% 53%

47 second advance: 5.0% behind, 22.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
2.8% 4.1% 4.1% 6.9% 8.3% 9.0% 9.7% 10% 12% 16% 16%

60 second advance: 7.7% behind, 19.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
8.3% 3.5% 6.9% 5.6% 7.6% 12% 9.7% 13% 8.3% 8.3% 17%

65 second advance: 15.3% behind, 11.3% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
12% 9.7% 15% 12% 14% 6.2% 8.3% 6.9% 4.8% 4.1% 4.8%

120 second advance: 7.6% behind, 16.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 12% 0% 11% 0% 18% 0% 33% 0% 22% 0%

290 second advance: 15.1% behind, 16.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
12% 12% 9.7% 7.6% 2.8% 5.5% 6.9% 7.6% 4.1% 5.5% 2.8%

=3D=3D=3D=3D=3D=3D=3D
The test script follows. Each file was run using:
ruby -rtest_fuzzy.rb <PersonFileName>
=3D=3D=3D=3D=3D=3D=3D

require 'test/unit'

$DEBUG =3D false

class Time
def to_fuzzy
s =3D strftime("%H:%M")
s[4] =3D "~"
s
end
def short
strftime("%H:%M")
end
def round_to( seconds )
seconds =3D seconds.round
Time.at( self.to_i / seconds * seconds )
end
end

RUNS_PER_SET =3D 1
class FuzzyTimeTester < Test::Unit::TestCase
def test_running
[ 2, 6, 17, 30, 47, 60, 65, 120, 290 ].each{ |advance_seconds|
runs, num_ahead, num_behind =3D 0, 0, 0
offsets =3D Hash.new(0)
=20
RUNS_PER_SET.times{
t =3D Time.at( Time.new + rand( 3600 * 300 ) )
end_time =3D t + 60 * 60 * 24 # Run for 24 hours
ft =3D FuzzyTime.new( t )
last_value =3D nil
while( t < end_time )
assert_equal t, ft.actual
t0 =3D Time.at( t - 60 * 5 )
t2 =3D Time.at( t + 60 * 5 )
legal_values =3D [ t0, t, t2 ].map{ |x| x.to_fuzzy }.uniq

fuzzy_fuzz =3D ft.to_s =20

if last_value
y,mon,day =3D t.year, t.mon, t.day
h,m =3D last_value.scan(/\d+/).map{ |s| s.to_i }
m *=3D 10
if (m -=3D 10) < 0
m %=3D 60
if (h -=3D 1) < 0
h %=3D 24
end
end
illegal_old_value =3D Time.local( y,mon,day,h,m ).to_fuzzy
legal_values -=3D [ illegal_old_value ]
if $DEBUG
puts "Now: %s=3D>%s; legal: %s (was %s, can't be %s)" % [
t.short, fuzzy_fuzz,
legal_values.inspect, last_value,
illegal_old_value
]
end
end
=20
assert_block( ( "It is %s, the clock displayed %s,\n" +
"but it should only display one of %s.\n" +
"(Last time I asked, it said it was %s.)" ) % [
t.short, fuzzy_fuzz.inspect,
legal_values.inspect,
last_value
] ){
legal_values.include?( fuzzy_fuzz )
}
=20
actual_fuzz =3D t.to_fuzzy
ahour, amin =3D actual_fuzz.scan( /\d+/ ).map{ |x| x.to_i }
fhour, fmin =3D fuzzy_fuzz.scan( /\d+/ ).map{ |x| x.to_i }
if fuzzy_fuzz !=3D actual_fuzz
if fmin>amin || fhour>ahour || ( fhour=3D=3D0 && =
ahour=3D=3D23 )
num_ahead +=3D 1
else
num_behind +=3D1
end
end
=20
if fuzzy_fuzz !=3D last_value
ahour2, amin2 =3D t.short.scan( /\d+/ ).map{ |x| x.to_i }
if fmin>amin || fhour>ahour || ( fhour=3D=3D0 && =
ahour=3D=3D23 )
offset =3D ( fmin*10 - amin2 ) % 60
else
offset =3D ( fmin*10 - amin2 )
end
offsets[ offset ] +=3D 1
if $DEBUG
puts ( "It is %s, I just switched from %s to %s, " +=20
"and I think that's an offset of %+d" ) % [
t.short, last_value, fuzzy_fuzz, offset
]
end
end
runs +=3D 1 =20
last_value =3D fuzzy_fuzz
ft.advance( advance_seconds )
t +=3D advance_seconds
end
}
=20
puts "%d second advance: %.1f%% behind, %.1f%% ahead" % [
advance_seconds,
100.0 * num_behind / runs,
100.0 * num_ahead / runs
]
total_offsets =3D offsets.inject(0){ |sum,kv| sum+kv[1] }
-5.upto(5){ |o|
print "#{o>0?'+':''}#{o}".center( 5 )
}; print "\n"
-5.upto(5){ |o|
pct =3D 100.0 * offsets[o] / total_offsets
print( ( "%.#{(pct<10&&pct>0)?1:0}f%" % pct ).center( 5 ) )
}; puts "\n "
}
end
end

 
Reply With Quote
 
 
 
 
Marcel Ward
Guest
Posts: n/a
 
      11-02-2006
On 02/11/06, Gavin Kistner <(E-Mail Removed)> wrote:
> The second line is the result of recording, each time the fuzzy time
> changed, how many minutes ahead or behind the actual time the change
> occurred. Ideally, you should see the same percentages spread along the
> whole range.


I see now why the quiz mentioned that we might need to assume a
regular observation period of e.g. 7 seconds - to allow us to even out
the distribution of times. However, to do this would also require
that we know what the total duration of the observation was.
Otherwise surely the only solution to ensure roughly average counts of
-5 to +5 would be to start by wandering slowly from -5 mins to +5 mins
then back (a bit more quickly) to -5 mins again... and repeat?

Then after doing that a few times you might think you can become a bit
more random and wiggle the wandering a bit... but who's to say that
the observer isn't going to start the statistics from this point on?
Then you're going to look a bit silly with all that extra wiggling and
not averaging out the times.

So better stick to just wandering back and forth, back and forth like
clockwork... is this random?

When I tried increasing the RUNS_PER_SET value in Gavin's
FuzzyTimeTester from 1 to about 15, I noticed some results take on a
more gaussian distribution with a slight weighting to the right
because of the "can't go back in time" condition.

I'm starting to think that this may be the only truely random result
given some of the conditions of the quiz... but I hope I can be proved
wrong!

Now looking forward to the conclusion and letting my brain relax at last

--
Marcel

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
[SUMMARY] Fuzzy Time (#99) Gavin Kistner Ruby 0 11-02-2006 10:52 PM
[QUIZ] Fuzzy Time (#99) Ruby Quiz Ruby 22 11-01-2006 11:07 PM
Fuzzy Logic Library VisionSet Java 3 12-12-2005 10:32 PM
algorithm for generating top fuzzy variations ... Giovanni Azua Java 3 08-09-2005 01:57 PM



Advertisments