Andrew Que Sites list Photos
Projects Contact
   On my Blue Mounds camping trip, I tried some star photography and turned out some of the best results I've yet had.  There was a little light pollution from the direction of Madison, but the skies were pretty clear.  I could just barely see the Milky Way and captured it a bit in some of my shots.  My camera couldn't figure out how to do exposure to my satisfaction, so I did the shots completely manual.  At this point there were still embers in the fire I could use as a distant object to get focus.  Once focus was set, I switched to manual focus and left the lens alone.  I did not bring a tripod and use the picnic table at my camp site as a stable base for the pictures.  Most shots used a 30 second shutter time.  There is a bit of streaking from the star movement, but it's not bad.

October 16, 2015

Ranged Random Numbers with Gaussian distribution

I've written in the past about various algorithms I came up with for getting weighted random numbers, but ever since leaning the Box-Muller transform I've been refining my ideas. The Box-Muller transform allows the generation of random numbers with Gaussian distribution. That is, a set of numbers with a known standard deviation. That, in turn, allows for the generation of numbers with some standard statistical properties.

Today I needed a random number between two values, but I wanted something with a known standard deviation. Gaussian distribution does not have a minimum and maximum, theoretically capable of giving any number between negative infinity to positive infinity. However, standard deviation tells us that around 68.2% of the values will be within 1 standard deviation, 95.4% with in 2, and 99.73% with in 3 standard deviations. So by dividing the output of the Box-Muller transform by 3, 99.73% of these values will be between -1 and 1, and only 0.27% will be outside this range. If we ignore values outside this range we can generate a ranged random number generator with a given standard deviation.

Let us first start with the Box-Muller transform.

There are two inputs, r1 and r2, and two results. The inputs are random values such that 0 ≤ rn ≤ 1. Since there are two input values, there are also two output values. The output is such that -∞ < x < ∞. The Box-Muller transform is kind of the unit circle of Gaussian distribution with 68.2% between -1 and 1, 95.4% between -2 and 2, 99.73% between -3 and 3, and so forth. Multiplying the output of the Box-Muller transform will result in a stream of numbers with a standard deviation of the multiplicand.

Now to get this into a fixed range we just need to scale the results. The problem is that input range is infinity. However, we know that most of the values are closer to the center. So we can simply discard values outside of the desired standard deviation. To illustrate this, let's say we want numbers on average around 75 between 50 and 100 with a standard deviation of 8.

Let xn be the output of the Box-Muller transform. To get a known standard deviation we need to scale down xn. Let s be the scale factor. s= 2d/Δ where d is the desired standard deviation, and Δ=max-min. For our example, d=8, and Δ=(100-50)=50. Thus s = 0.32.

Let y = s xn. Now discard any y where |y| > 1. That is, if the results are larger than one, get a new random number and try again. We now have a value y such that -1 ≤ y ≤ 1, and that we can scale to the desired range. Let z = y Δ/2+ Δ/2+m where m is the minimum value and M is the maximum value. The result z is such that mzM.

Here is a graph of the example:


This chart shows 1,000 points generated at random with this algorithm. The actual standard deviation is 7.972 which is pretty close to the desired 8.0, average of 75.222, min of 51.950 and max of 99.961. So our algorithm seems to work.

There are some limitations to this system which I haven't yet been able to analyze in depth. This algorithms gets close to the desired standard deviation, but usually comes in under. My guess is that this is due to the amount of data discarded. The larger the standard deviation, the more data is discarded and thus the more this missing data effects the resulting standard deviation. This becomes really noticeable for standard deviation above 18%. For our example range of 50 to 100, 18% is 0.40 * (100-50) = 20. There may be a way to compensate for this by increasing the desired standard deviation to account, but I would have to dive more into the math to come up with a compensation factor.

Here is the C code for the algorithm:

double getGaussianRandom( double standardDeviation )
  static bool hasRandom = false;
  static double randomA = 0;
  static double randomB = 0;
  static double const TWO_PI = 6.283185307179586476925286766559005768394338502;

  double result;

  if ( ! hasRandom )
    randomA = sqrt( -2 * log( getRandom() ) );
    randomB = TWO_PI * getRandom();

    result = randomA * cos( randomB );
    hasRandom = true;
    result = randomA * sin( randomB );
    hasRandom = false;

  result *= standardDeviation;

  return result;

double getRangedGaussianRandom
  double min,
  double max,
  double standardDeviation
  double delta = ( max - min ) / 2.0;

  double result;
    result = getGaussianRandom( standardDeviation / delta );
  while ( fabs( result ) > 1.0 );

  result *= delta;
  result += delta;
  result += min;

  return result;

In this example, the function getRandom returns a number between 0 and 1, but has not been specified.

October 12, 2015

Bike Camping day 2



   I don't sleep well anywhere but home, and as I figured I would, I tossed and turned most of the night.  Still, I did sleep.  When I noticed the twilight around 6:30 am, I was ready to be awake.  The evening did nothing to help dry my clothing damp from the ride in, so in the future I will have to remember that.  Nonetheless, it wasn't cold or even chilly.  Just a cool morning.  I had some time before sunrise and so drank my last fruit juice and had some bread for breakfast.  Then I biked down to the Military Ridge Trail to look for a spot to catch the sunrise.  There were not a lot of clearing, but I did find one and spent at least 15 minutes capturing the sunrise.  The clouds in the sky made it glorious and I saved 46 shots.
   Seemed like I had just arrived, but it was time to go.  I could have biked around and explored more of the park, but I had planned on getting a full breakfast in Mt. Horeb.  Everything packed up with ease and was soon back on my bike.  In fact, the tent packed smaller than I started with as I used a pretty tight roll when I put it away.  With water refilled, the fire out and no trace I had ever been there, I departed.
   The plan was to take Military Ridge trail into Mt. Horeb and find a diner.  This is about a 5 mile ride, and this time the wind was at my back.  In addition, it was a steady drop in altitude the whole way.  I arrived in downtown Mt. Horeb and peddled down Main Street looking for a diner.  During my first pass I only saw coffee shops, but I wanted a diner.  At the end of the business section of Main Street on my return pass I found a tiny little diner that was exactly what I was looking for.  French toast, eggs, sausage and coffee--plenty of calories for the trip home.
   After breakfast I examined the map to see what my travel options where.  The fastest route home was to take the trail to Klevenville, then catch County P and snake my way north-east.  But I have done that route, and it is boring.  I opted for a longer route that would take me into Verona.  From the map I could see parks and bike trails heading north, and that was good enough for me.  From Mt. Horeb to Riley I lost the rest of the my altitude and things were fairly flat after that.  In Verona I found the trail I was looking for, but a section of it had been closed for construction.  It looked like people didn't really care, pulled down the caution tape, and went through anyway.  I opted to find the detour, which wasn't marked on the trail at all, but did manage to bypass the closed section of the trail.  I worked my way north, coming at last to Elver Park on the south west side of Madison.  I had been there once before, and knew the trails would take me most of the way home.  Soon I was back in Middleton and at 11:50 am my trip was over.
   In total I traveled 57.6 miles over 5 hours; 26.9 miles the first day, and 30.7 the next; and burned burned 3,218 Calories.  I have successfully completed my first bicycle camping trip and learned a lot from doing so.

October 11, 2015

Bike Camping

Loaded Down at Arrival

Loaded Down at Arrival

   With all my recent progress in biking distances, I decided I was finally ready for something I have talked about doing for at least 10 years: bike camping.  The camping season is usually over by October with the shorter cool days and often frigid nights.  However it has been unseasonably warm lately and the forecast for today called for a high of 80 °F (26.7 °C).  This would provide the perfect opportunity for accomplishing goal.
   Initially I wanted my first camping trip a group affair.  The idea was to meet a group of people at a camp site.  Should I have forgotten anything, I would have them to fall back on.  However, all the people I know talk a lot about wanting to go camping, but seldom actually do it.  So if I were going to make this trip, it would just be me.  And if I forgot anything, I would just have to live without it.
   For gear I just took the basics: sleeping bag, sleeping mat, tent, couple of toiletries, couple shirts (for the inevitable change in temperature), 2 liter of water, and my camera.  I had already lugged this around during my ride on Friday and found it didn't really effect anything.  I didn't notice the weight difference and I didn't notice a shift in speed.  So when packed up, I set out for Blue Mounds State Park.
   My route to the park took my via Cross Planes, then Vermont, and then on some winding back roads.  My body was tired from the previous days of biking and skating, and I had a 10 MPH wind from the south.  So my speeds and heart rates were not that high.  This was more difficult than my last ride to Vermont because I wasn't fatigued.  Still, I powered along, taking hills slowly and keeping my heart rate around 155 BPM (84.7%).  I made it to Elvers where I stopped to eat.  Fruit juice, banana, and fresh bread.  At this point I had cover no new ground and was already 19 miles into the trip.  From here I knew things were going to become more difficult.
   Just after Elvers I hit a low point at about 800 feet in elevation.  Heading south on county road F, I increased that to 1,130 feet in the next 1.8 miles, but the climb was fairly gentle.  I turned on to Moyer Road where in the next 1.25 miles I lost most of my gains.  Ryan Road was the last leg of the journey.  I would start at 880 feet and climb to 1,570 feet over the next 2.8 miles.  It was grueling and didn't let up--a hard way end finish a long ride.  I put the bike into granny gear and push away.  At times the grade was as high as 20% and I would have to zig-zag to make the climb.  I'm not sure what my speeds where, but they could not have been much about 5 MPH.
   A arrived at the park just before 6:00 pm.  The ranger was still there and I was able to avoid self-registration and get firewood.  I was a sweaty mess as I checked in, but I made it.
   The reason I choose Blue Mounds as my destination is because it has a bike in/hike in only campground situated away form the main campground.  I figured this was by more quite and less populated.  I found the main campsites were indeed pretty full, despite how late it is in the season.  However, the bike/hike campground would only have me and one other camper.
   I strapped a bundle of wood on top of the rear bag on my bike with a bungee cord I decided was a good idea to cart along, and made my way to my campsite.  There was less than 20 minutes until sunset so after I arrived I wasted no time in pitching the tent and getting it ready.  Here was my first round of faith.  James had lent me his tent.  I had never used or even seen this tent before, nor had I checked to see that everything was there before I left.  But, the tent was perfect.  It went up quickly and I soon had it setup with my sleeping bag inside.  Then it was time to build a fire.  I brought some news paper with me as I figured with the high humidity getting leaves to lite wasn't going to be fun.  This allowed me to have a fire going in minutes.  That would provide the light for the rest of the evening.  Now it was time to eat.  I had just baked some bread and made myself two 6" submarine sandwiches.  I did not take long to make the sandwich disappear, along with one of my apples.  Fed, and the daylight now gone, I got into the tent.  It was still quite early, but with all the days exertion I was exhausted and passed out quickly.
   I woke up around midnight and was hungry.  So I got up, restarted my fire from some hot coals, and ate my other sandwich.  The stars were quite vivid and I could see the faintly see the Milky Way.  I decided to try a little photography using a timer and setting my camera on various stable surfaces for long exposures.  The result were really good, probably some of the best star photography I've yet done.
   Saturday is skating day, and my goal was again 2,000 Calories for the 3 hour session.  I didn't eat as well as I had last weekend, and I think I was dragging a little from yesterday's and this afternoon's bike ride.  Yesterday totaled 33 miles, and this afternoon I added an other 14 biking downtown.  I thought I had a large enough lunch, but was hungry before I started skating.  So I stopped for some quick sugar (candy bar and apple juice).  That helped.  On the skating floor I wasn't pushing very hard, especially at the beginning of the night.  As the session went on I dug in a little more.  I found my stamina is higher than several of the other regular skaters.  Skaters often form lines where our steps stay in unison to the beat of the music.  I've heard this called both two-stepping and jam skating, although I'm not sure of the correct title.  This synchronized line typically moves pretty fast for the duration of a song.  Early in the night I had one of the better skaters start to follow me for a song.  It was a faster song with periods of build-up.  Although the tempo didn't change, I would speed up during the build-ups.  My tail stayed on me for the first few laps, but as I kept accelerating I lost him.  During an other song a line began to form.  I slowed down from my normal speed to join in, and compensated for the lack of speed with more exaggerated motions.  Jam skating is, after all, a form of dancing on skates.  I found this can keep my heart rate at 170 BPM (92.9%) despite the slower pace.  It also requires more coordination because not only do you have to stay in sync with the person in front, but you are also operating quite close to them.  Part of the reason lines looks so neat is because of how close everyone is while operating in unison.  Our lead person stated she was unable to maintain our pace, and with about 40 seconds left in the song broke off and the line dissolved.  I actually sped up.  I pass 2,000 Calories at the last song of the evening covering a time span of 2 hours, 51 minutes.  This is a burn rate of 711 Calories/hour, 5% lower than last weekend where I was burning at the rate of 743 Calories/hour.  My average heart rate was 144 BMP (78.7%) and only topped out at 179 BMP (97.8%), down from last weekends top end of 184 BPM (100.6%).  Still, my 2k goal was met and I had a big slice of pumpkin cheesecake at the diner afterward.

October 09, 2015

Quick Trip Gone Long

Quintessential Wisconsin

Quintessential Wisconsin

   I had planned to do a quick ride to Governor Nelson State Park just a few miles away to pick up a trail pass.  When I got there I found no one manning the ranger station so I wasn't able to buy a pass.  But rather than just go home, I decided I would bike up to Waunakee and get an apple from the grocery store.  Once I had my apples and some fruit juice, I decided I should go visit the wind turbines with the goal of logging 25 miles for the day and started west.  At the wind turbines, I ate my second apple and finished off my juice and decided to take a rode I had never traveled into Ashton.  After reaching Ashton, I decided 25 miles wasn't going to be enough.  So I turned west and traveled down County Road K for a mile or two.  Found a farmer with a little stand selling apples, and despite having already eaten two, I picked up an other.  I normally don't eat much fruit, but I've taken a real liking to apples lately.  I came to Vosnes Road before heading south to Schneider Road.  I was pretty sure this would allow me to get 30 miles for the trip.  I took Schneider into Middleton and snaked my way through the Northside and Middleton Hills subdivisions.  When I got back to the house, my quick ride had turned into 33.86 miles over 3 hours, 7 minutes, burning some 2,150 Calories.  Needless to say, some heavy eating followed.
   What I find interesting about my body at this fitness level is the load at which it is comfortable.  On the way out to Governor Nelson, I just felt like pushing hard.  My heart rate maintained a rate between 165 (90.1%) to 175 (95.6%) beats/min.  And this was comfortable—I didn't feel I was straining to achieve these levels.  If my heart rates on the stationary bike are anything to go by, these heart rates are between 300-400 watts of power output.  I can maintain 300 watts of power with a heart rate between 160 and 170, which the average being 164 BPM.  I can do over 350 watts for 10 minutes at around 169 BPM, and although I can't hold it I can produce over 400 watts for short periods of time.  I have also noticed how quickly my heart rate will slow down after a hard push.  Most of the ride after the park was at a rate around 155 BPM (87.4%), but on hills I would often jump to over 165 BPM.  It wouldn't take long after the top for me to be back down at the lower rates.  Makes me want a better heart monitor and some way to measure power output on my bike.  I have ideas about how to do this, but haven't started on any of them.
   Pretty good headwind all day during the ride as the winds were out of the north at 10 MPH.  Gave me a pretty good boost at the end of the ride though as I was heading south.  The temperatures were in the upper 50s.  I found my wicking shirt I bought for winter riding is really nice for this kind of weather.  Kept me warm, but not overly so.  And since it was fully uncovered in the wind, I dried off pretty quickly after powered sections of riding like hill climbs.  It was a much more comfortable ride than last weekend.
   The fall colors are still getting a state, but have clearly begun.  I stopped few times to get pictures during the ride, and a week or two from now is going to be really lovely.
My Metal Horse X-Cal

My Metal Horse X-Cal

   My trusty metal horse.  This beast weights a lot for a bicycle, but that is because I seem to like hauling everything.  I know there are over 1,000 miles on this bike, but since the odometer stopped working a few years ago I don't really know how many more.  The seat has sure seen better days.  Last year I had to replace the back tire.  I had a flat and the tire was pretty much shot with all the knobs were worn away on the center.  I've been through a lot of inter-tubes, a couple of chains, and a rear cassette that I can recall.  But this bike has served me very well considering how badly I treat it.  I have a bad habit of forgetting to oil anything.  Luck for me the guys at the bike shop are always able to recover the damage I inflict, and most of the time my bike rides really smoothly.  I love my metal horse.