I was having some semi-regular trouble sleeping, with some suspicion that it might be related to the amount of coffee I was drinking. And because I am exactly that nerdz0r, I performed I pseudo-double-blind experiment on myself to see if it really was the coffee.
Method:
Bought two batches of beans from the same roaster, one decaf and one normal. Put them in identical containers, with a label (A or B) on the back of each. Got Coz to secretly record which was the decaf and which the real. Every day when I'd have a coffee, I'd mix the two containers around and pick one for the beans, all without being able to see the labels (so I wouldn't prejudice myself against A or B...) I blindly took a picture of the label to record which I'd used (mostly) without knowing (I'd occasionally catch a glimpse, but not often enough that I ended up with any consistent view of which was A and which B.) I'd also record when I'd been to bed the night before, when I'd woken up, and how well I'd slept.
Note1: I'm crap at remembering to note this stuff down, so there were a number of days where I recorded my sleep data the next day (less reliable) or couldn't remember anything at all.
Note2: I proceeded to have almost none of the sorts of nights that caused me to do the experiment in the first place (bed at 12, up at 4am and unable to get back to sleep at all.)
Then I tried to characterize the sleep for a night as disturbed or not purely from the descriptions: any mention of waking in the night - even if I got back to sleep easily - staying up particularly late, or waking particularly early counted, and the day before that night marked with a *.
Then I went back through the photos and filled in A and B for which beans I used on each day. Miraculously, only one of the blind photos completely missed the label.
Analysis:
trouble sleeping after A: 4
trouble sleeping after B: 3
slept soundly after A: 7
slept soundly after B: 8
trouble sleeping after unknown: 1
slept soundly after unknown: 1
trouble sleeping after knowingly drinking real coffee: 2
slept soundly after knowingly drinking real coffee: 1
Conclusions:
Not enough data for anything truly statistically significant, but damn but that looks pretty even. Doesn't look like caffeine had much effect.
Raw Data:
*July 3: Slept well, woke 11 am. coffee B @ 4. bed 12:45 am. read 20 mins or so
July 4: Woke twice in the night, but back to sleep fine both times. Woke 11 am. coffee A @ 2. bed 12:15, read ~20 mins.
*July 5: Woke once for maybe 5 mins. Woke 8ish when Coz got up. coffee ? @ 1:30. bed 12:15. Fell asleep playing phone games within 10...
July 6: Woke ~6am and distracted myself awake putting the phone games (still running!) away. Never did go back to sleep. coffee A @ 11:30. bed 12:15. read til 1.
July 7: Slept well, woke 9. coffee B @ 1:45. bed 11:30.
July 8: Slept well, woke 9. coffee A @ 2. bed 12:30.
*July 9: Slept well, woke 6:30. coffee A @ 1. read in bed til 3:30 ish
July 10: Woke 11. coffee B @ 2:45. bed 11:30.
July 11: Slept well - woke a couple of times but always straight back to sleep. Woke 10:30. coffee A @ 2:45. bed 1.
*July 12: Slept well, woke 9. coffee A @ 3:30. bed 12:30
*July 13: Slept well, woke 9:30. 1 real espresso @ 11. bed 12ish
July 14: woke 4:30 and stayed awake playing silly games. Nodded off and slept again for an hour and a bit? 1 coffee ? @ 1.
*July 15: Slept well; can't remember when I got up. coffee A @ 3:15. Bed 1ish.
July 16: Woke 6, read til 9, slept til noon. coffee B @ 3:30. Bed 11:30; read til at least 12.
July 17: Slept well; woke once but straight back to sleep. Woke 9. coffee B @ 1:30. bed 12:15.
*July 18: Slept well. Woke 9. coffee B @ 3:30. bed 12:30; read til at least 1.
July 19: Slept well til 6, woke and read / played til 9, back asleep and woke at 1pm. 1 coffee A @ 3.
July 20: coffee A @ 1.
*July 21: 2 real coffees @ 1 and 2. Bed 12:30 but up late reading.
July 22: Awake @ 8:30 playing on the tablet. coffee B @ 1.
July 23: coffee B @ 3.
*July 24: Slept well. Woke 9ish. coffee B @ 3. Bed 1.
July 25: Woke a couple of times in the night but straight back to sleep. coffee B @ 2:30. Bed 12:30-ish.
July 26: Slept like a stone. Woke 8:30, fell back asleep reading woke again 10:30. coffee B @ 2:30. Bed 1.
July 27: Slept fine. Woke 9-ish. no coffee? Bed 1:30.
July 28: Slept fine. Woke 9. coffee B @ 2:15. Bed 12:30.
*July 29: Woke 9. coffee A @ 2:45. 2nd decaf an hour later. Bed 11:30.
July 30: Woke 4:30 briefly, then again at 7:30 and read. coffee A @ 1.
July 31: ? Up 9. one of each coffee @ 2ish (couldn't tell them apart.) Bed 12:30.
Aug 1: real coffee @ 7pm. Bed 1.
Thursday, August 1, 2019
Monday, July 21, 2014
RFID Shielding
Got a new employee id card today - which is also the RFID card that gets us through the door sensors - and a new ecoPass - the pass that gets us on the local buses for free. The latter used to be just a sticker that went on the former, but the buses are moving to RFID as well, so now its a card. Obviously, they conflict with one another; while the ecoPass is in my wallet, the id card won't open doors.
Googled round a bit about RFID interference and shielding, and ended up trying a piece cut out of the back of a Coke can - cut it a couple of mm too big in every direction and fold the edges over to avoid sharp bits. With this between the two cards, one side of my wallet (the id side) now opens doors again. I assume the ecoPass should work from the other side of my wallet, though I haven't tested that yet.
As you can see from the back shot, I eyeballed the dimensions and got it too short to cover the complete back of the card; this doesn't appear to matter.
Googled round a bit about RFID interference and shielding, and ended up trying a piece cut out of the back of a Coke can - cut it a couple of mm too big in every direction and fold the edges over to avoid sharp bits. With this between the two cards, one side of my wallet (the id side) now opens doors again. I assume the ecoPass should work from the other side of my wallet, though I haven't tested that yet.
As you can see from the back shot, I eyeballed the dimensions and got it too short to cover the complete back of the card; this doesn't appear to matter.
Friday, May 16, 2014
Pounding the Pavement
Sent this in to Randall at xkcd for his What-If column (Randall - on the very long odds that you like my question _and_ end up hitting this obscure little auto-blog; no peeking!)
Which exerts more pressure on the roadway; 200-pound me on my 30-pound mountain bike, or the 6-million-pound crawler-transport (that used to be) used to take the space shuttle to launch?
On my way to work this morning, I distractedly rode my mountain bike across some reasonably-fresh asphalt. I worried whether I might have left a mark. This got me thinking about the relative pressure - in the real sense; per unit-area - exerted by me and my bike. I may be light compared to, say, a car, but the contact patches of my tires are pretty miniscule.
Several sources suggest the pressure exerted on the ground by a tire should be exactly equal to the pressure in the tire, but fail to back this up with experimental evidence. This http://www. performancesimulations.com/ fact-or-fiction-tires-1.htm refutes that and does site evidence, so I'll do it the hard way.
This was useful for contact patch sizes for mountain bikes: http://bansheebikes.blogspot. com/2013/11/wheel-size-facts- part-3-contact-patch.html. Ends up about 4.19 in^2. Those calculations are for ~32 PSI in the tires, which seems ludicrously low to me, but they're probably talking about dirt-track riding - I rarely get off the pavement anymore, and keep mine up around 60 PSI. But, it also finds pretty tiny amounts of variation, so I'll hope that doesn't skew it too much (and in any case higher PSI would _decrease_ the size of my contact patches, and therefore _increase_ the pressure on the pavement.) I weigh about 200 lbs, and my bike weighs about 30 lbs, so 230 lbs / 4.19 in^2 =~ 54.89 PSI. (Which is actually pretty close to my tire pressure, but that's probably coincidence given the contact patch size was estimated using a different pressure.)
This http://airandspace.si.edu/collections/artifact.cfm?object=nasm_A19730875000 give me the dimensions of a single tread on one of the tracks of the crawler: 90" x 25" x 18". Height should be the shortest, so I'm going with 2250 in^2 of contact patch. This http://en.wikipedia.org/wiki/Crawler-transporter says it has 4 tracks with 57 treads each, but the photo down the bottom shows 33 in the air, so 24 on the ground at a time per track. 24 x 4 x 2250 = 216,000 in^2 of contact patch. It also lists the curb weight at 5,999,000 lbs (I do _not_ weigh 6 million pounds! How dare you!) leaving us with 27.77 PSI. Me and my bike are pushing nearly twice as hard.
(Of course, in an ideal mathematical model the contact patches of a tire would be infinitesimally small at the point of first contact - they're bigger because either the tire or the road surface deforms. I'm pretty sure I know which deforms most easily in the cases of: a rubber air-filled tire, asphalt, and metal treads.)
I wonder how big the contact patches are on my rollerblades?
Which exerts more pressure on the roadway; 200-pound me on my 30-pound mountain bike, or the 6-million-pound crawler-transport (that used to be) used to take the space shuttle to launch?
On my way to work this morning, I distractedly rode my mountain bike across some reasonably-fresh asphalt. I worried whether I might have left a mark. This got me thinking about the relative pressure - in the real sense; per unit-area - exerted by me and my bike. I may be light compared to, say, a car, but the contact patches of my tires are pretty miniscule.
Several sources suggest the pressure exerted on the ground by a tire should be exactly equal to the pressure in the tire, but fail to back this up with experimental evidence. This http://www.
This was useful for contact patch sizes for mountain bikes: http://bansheebikes.blogspot.
This http://airandspace.si.edu/collections/artifact.cfm?object=nasm_A19730875000 give me the dimensions of a single tread on one of the tracks of the crawler: 90" x 25" x 18". Height should be the shortest, so I'm going with 2250 in^2 of contact patch. This http://en.wikipedia.org/wiki/Crawler-transporter says it has 4 tracks with 57 treads each, but the photo down the bottom shows 33 in the air, so 24 on the ground at a time per track. 24 x 4 x 2250 = 216,000 in^2 of contact patch. It also lists the curb weight at 5,999,000 lbs (I do _not_ weigh 6 million pounds! How dare you!) leaving us with 27.77 PSI. Me and my bike are pushing nearly twice as hard.
(Of course, in an ideal mathematical model the contact patches of a tire would be infinitesimally small at the point of first contact - they're bigger because either the tire or the road surface deforms. I'm pretty sure I know which deforms most easily in the cases of: a rubber air-filled tire, asphalt, and metal treads.)
I wonder how big the contact patches are on my rollerblades?
Monday, April 15, 2013
Oribitals
How big should you make a ring-shaped orbital to get a 24-hour day?
Centrifugal acceleration a = v^2 / r
9.8 m / s^2 = v^2 / r
v = 1 rev / day = 2 * pi * r / 86400 s
9.8 m / s^2 = (2 * pi * r / 86400 s) ^ 2 / r
= 5.289 * 10 ^ -9 * r
r = 1,853,078,528.45 m =~1.85 million km.
Yep, Banks got it about right.
Centrifugal acceleration a = v^2 / r
9.8 m / s^2 = v^2 / r
v = 1 rev / day = 2 * pi * r / 86400 s
9.8 m / s^2 = (2 * pi * r / 86400 s) ^ 2 / r
= 5.289 * 10 ^ -9 * r
r = 1,853,078,528.45 m =~1.85 million km.
Yep, Banks got it about right.
Friday, December 14, 2012
This is the first time I've seen anyone make this connection in a scientific fashion. Check the research is solid before repeating it.
http://www.newscientist.com/article/dn17922-carrying-a-gun-increases-risk-of-getting-shot-and-killed.html
Sunday, October 28, 2012
Cones
Geekin out the maths, and might actually have a use for this again someday. How to custom-design a piece of a cone, to step a cylinder of one size down to another.
I want to step a cylinder of radius r1 down to a new radius r2 over a distance of d. This is a section "trimmed" off the top edge of a cone, so the trick is to first describe the cone. The height of the full cone (h1), the length of its side (s1), and the radius of the larger disk (r1) form a right triangle. Next describe the smaller cone we're cutting off the tip of the larger. The height of the offcut (h2), the length of its side, and the radius of the smaller disk (r2) also form a right triangle. The angle between the height and the side in each of these triangles must be identical. The tangent of that angle is the ratio of the radius over the height, and it also must be identical between the two triangles, so r1/h1 = r2/h2. r1 and r2 were given, and h1 = h2 + d, so we solve for h2:
r1*h2 = r2*h1
h2 = r2/r1*(h2+d)
h2*(1-r2/r1) = r2/r1*d
h2 = r2/r1*d/(1-r2/r1)
h2 = d*r2/(r1-r2)
To draw a template for this cone on flat paper we need a circular sector. The radius of this sector is the length of the side of the cone, which is just the hypoteneuse of the first triangle we described above: s1 = (r1^2 + h1^2)^(1/2). The angle of the sector - effectively, the proportion of a whole disk we use - we can find from the fact that the outer circumference of the sector (not including the "pie cuts") must be equal to the circumference of the base of the cone, which is the disk with r1 from way back in the problem definition. So portion of the disk to use is the ratio of (2*pi*r1)/(2*pi*s1), or simply r1/s1.
So in my case I want to go from a diameter of 5/8" to 3/8" in the course of 3/8". To make life easier, I'll do everything in 16ths.
r1 = 5
r2 = 3
d = 6
h2 = 6*3/(5-3) = 9
h1 = 15
s1 = (5^2 + 15^2)^(1/2) = 15.81
s2 = (3^2 + 9^2)^(1/2) = 9.49
And I want 5/15.81 = 31.62% or 113.84 degrees.
But OpenOffice Draw is not a CAD program, and it won't let me specify the number of degrees in a sector. *grumble*. So subtracting 90 for the orientation, I get sin(23.84) = 0.40, and draw the sector out til its 1.40 inches long with a radius of 1.
(And confirmed by the "print-it-out-and-build-it method...)
I want to step a cylinder of radius r1 down to a new radius r2 over a distance of d. This is a section "trimmed" off the top edge of a cone, so the trick is to first describe the cone. The height of the full cone (h1), the length of its side (s1), and the radius of the larger disk (r1) form a right triangle. Next describe the smaller cone we're cutting off the tip of the larger. The height of the offcut (h2), the length of its side, and the radius of the smaller disk (r2) also form a right triangle. The angle between the height and the side in each of these triangles must be identical. The tangent of that angle is the ratio of the radius over the height, and it also must be identical between the two triangles, so r1/h1 = r2/h2. r1 and r2 were given, and h1 = h2 + d, so we solve for h2:
r1*h2 = r2*h1
h2 = r2/r1*(h2+d)
h2*(1-r2/r1) = r2/r1*d
h2 = r2/r1*d/(1-r2/r1)
h2 = d*r2/(r1-r2)
To draw a template for this cone on flat paper we need a circular sector. The radius of this sector is the length of the side of the cone, which is just the hypoteneuse of the first triangle we described above: s1 = (r1^2 + h1^2)^(1/2). The angle of the sector - effectively, the proportion of a whole disk we use - we can find from the fact that the outer circumference of the sector (not including the "pie cuts") must be equal to the circumference of the base of the cone, which is the disk with r1 from way back in the problem definition. So portion of the disk to use is the ratio of (2*pi*r1)/(2*pi*s1), or simply r1/s1.
So in my case I want to go from a diameter of 5/8" to 3/8" in the course of 3/8". To make life easier, I'll do everything in 16ths.
r1 = 5
r2 = 3
d = 6
h2 = 6*3/(5-3) = 9
h1 = 15
s1 = (5^2 + 15^2)^(1/2) = 15.81
s2 = (3^2 + 9^2)^(1/2) = 9.49
And I want 5/15.81 = 31.62% or 113.84 degrees.
But OpenOffice Draw is not a CAD program, and it won't let me specify the number of degrees in a sector. *grumble*. So subtracting 90 for the orientation, I get sin(23.84) = 0.40, and draw the sector out til its 1.40 inches long with a radius of 1.
(And confirmed by the "print-it-out-and-build-it method...)
Sunday, April 8, 2012
multi-dimensional hash slices in Perl
I've tripped over this enough times that you'd think I'd remember it by now, but I never do. And looking up the answer on google always seems to take me an age. So, in keeping with the title of this blog, I shall squirrel it away here in hopes that I'll remember to look here first next time...
I love slices in perl. They're brilliant. But they really don't quite do what you wish they'd do if you're trying to take a slice in the first dimension of a multi-dimensional hash. So if I've got:
%thing = ( "A" => [ "A0","A1","A2","A3" ],
"B" => ["B0","B1","B2","B3"],
"C" => ["C0","C1","C2","C3"]
);
I can happily slice up the last dimension on a constant "column" of the first:
print join ", ", @{$thing{B}}[1..2], "\n";
I can't do the reverse:
# doesn't work
#print join ", ", @thing{B..C}[1], "\n";
There are a couple of ways around this, some of which only work in certain circumstances:
print join ", ", ( map {$_->[1]} @thing{B..C} ), "\n";
works for output, but you don't have a ref to the original object anymore, so you can't change it. So while:
foreach ( @{$thing{B}}[1..2] ) {
s/B/E/;
}
Does what you'd expect - changes the values in B1 and B2:
foreach ( map {$_->[1]} @thing{B..C} ) {
s/1/4/;
}
...doesn't do the equivalent. Instead you need something like:
foreach ( B..C ) {
$thing{$_}[1] =~ s/1/4/;
}
(All of which seems pretty trivial from those examples, but when you try to do something complicated then being able to do all the referencing in the foreach parameter, and just work with $_ inside makes the code a LOT easier to read...)
I love slices in perl. They're brilliant. But they really don't quite do what you wish they'd do if you're trying to take a slice in the first dimension of a multi-dimensional hash. So if I've got:
%thing = ( "A" => [ "A0","A1","A2","A3" ],
"B" => ["B0","B1","B2","B3"],
"C" => ["C0","C1","C2","C3"]
);
I can happily slice up the last dimension on a constant "column" of the first:
print join ", ", @{$thing{B}}[1..2], "\n";
I can't do the reverse:
# doesn't work
#print join ", ", @thing{B..C}[1], "\n";
There are a couple of ways around this, some of which only work in certain circumstances:
print join ", ", ( map {$_->[1]} @thing{B..C} ), "\n";
works for output, but you don't have a ref to the original object anymore, so you can't change it. So while:
foreach ( @{$thing{B}}[1..2] ) {
s/B/E/;
}
Does what you'd expect - changes the values in B1 and B2:
foreach ( map {$_->[1]} @thing{B..C} ) {
s/1/4/;
}
...doesn't do the equivalent. Instead you need something like:
foreach ( B..C ) {
$thing{$_}[1] =~ s/1/4/;
}
(All of which seems pretty trivial from those examples, but when you try to do something complicated then being able to do all the referencing in the foreach parameter, and just work with $_ inside makes the code a LOT easier to read...)
Subscribe to:
Posts (Atom)