Wednesday, August 27, 2014

Clustering vs. Linear Regression - which to use?

I've got some data and I'm trying to make an informed decision whether it is better described by a linear regression or a set of clusters.

My goal here is to compare linear regression and clustering for some cases that are obviously better for one of these or the other, using 2-dimensional data that is easy to visualize.  By comparing these two workhorse methods under these conditions I'm hoping to gain better understanding of each and of how to decide when to use one or the other.

The 3 data sets I used were:
  1. "obviously" better described by linear regression
  2. "obviously" better described by clustering
  3. in between the above 2 extremes
I used R.  The scripts I used are present in this repository:
https://github.com/dllahr/cluster_vs_linear_regression

I got the code for clustering from:
http://www.statmethods.net/advstats/cluster.html

Before we get started:  my friend Phil Montgomery who kindly reviewed this post made a good suggestion that in general, when you have 2 models and you are trying to decide which one to use, you want to compare the statistical likelihood of each.  Usually this is done by comparing different values of parameters for a mathematical model, but it is worth investigating if it has been done for comparison of these two systems.

Sunday, August 10, 2014

Raspberry Pi RAID array

I largely followed these very helpful instructions:
http://www.davidhunt.ie/raid-pi-raspberry-pi-as-a-raid-file-server/

also useful:
http://ubuntuforums.org/showthread.php?t=408461
http://en.wikipedia.org/wiki/RAID
http://en.wikipedia.org/wiki/Mdadm

ingredients
  • 2 1-TB western digital drives
    • USB hub with power supply for these
      • Edit: make sure it has enough power to power the drives! My initial one (pictured below) did not and I suspect it was drawing power from the pi causing it to crash
  • raspberry pi
    • USB power supply for this (separate from above)
  • 8 GB sandisk microSD card
    • for use in raspberry pi
    • microSD card reader
  • cables to connect all

Saturday, June 28, 2014

Matlab solar system trajectory simulation

I wrote some code to simulate the trajectory of an object through a grossly simplified version of the solar system.  It uses the ordinary differential equation solver that comes with Matlab, some Newtonian physics, only has the Sun, Earth and Moon, and only uses idealized, circular orbits for those.  The code is here in this github repository:
https://github.com/dllahr/Matlab_solar_trajectory_sim

It's kind of fun to play with and someday I'd like to make an interactive web browser version of it, using perhaps this javascript library for numerical calculations:
http://numericjs.com/

Update - important note:  I have subsequently learned about the problem of energy drift which is when using basic differential equation solvers on even simple Newtonian systems, the result will have the system's energy increasing over time - sometimes even exponentially!  There are another class of differential equation solvers (Verlet Integration, Sympletic Integrator) that address this problem, the solar system trajectory code above should be updated to use these instead.

Tuesday, May 6, 2014

Peanut butter porter - the bottling

I bottled the peanut butter porter today, I used ~5/8 cup of dry malt extract for the sugar, boiled in water ~5 minutes, added to the beer as I was transferring from the carboy to the bottling bucket.  The material left over in the carboy was an oily mess, and based on that and what I tasted, I'm hopeful that most / all of the oil was left behind and the beer in the bottles is not oily.  However, I tasted it and it didn't really taste like peanut butter!

Monday, April 28, 2014

Video about BARD

My co-workers made a video about the BARD project, it is short but a great explanation of why BARD is needed and what it does.  Please consider checking it out and if you like, lick the thumbs up button:
https://www.youtube.com/watch?v=j9Z00y6g1iQ

Sunday, April 6, 2014

Carob Porter - the conclusion

Had a bottle of the Carob Porter on 2014-03-02 - at room temperature - tasted pretty good.  Bottom of bottle was covered in sediment, but the poor into the glass was not cloudy.  It is a very dark beer.

I continued to drink it on an almost daily basis and found it quite enjoyable.

Brewing a peanut butter porter - the wort

I began work the peanut butter porter today.  Ingredients:

12.75 oz. (includes plastic bag though) of grains (2/3 crystal malt, 1/6 black patent, 1/6 roasted barley)
3/4 oz. crystal hop pellets
1/2 cup brown sugar
1/2 cup blackstrap molasses
5 3/4 oz. corn sugar
2 1/4 oz. regular sugar
11 5/8 oz. CBW special dark malt extract (Briess)
1.5 lb. DME CBW special dark
1/2 lb. peanut butter, including oil on top, Teddie natural
1/8 oz. galena hops

I ground up the grain using the grain mill of our kitchenAid (coarsest setting, slowest speed), added it to 0.75 gallons of water in a 2.5 gallon pot, put it on high heat.

Sunday, March 23, 2014

Peanut butter in water - doubling the amount

A quick experiment today around boiling peanut butter in water.  I doubled the amount of peanut butter to 56 g in 1 cup of water.  During the boil it formed a complete emulsion, as far as I could tell there was no water, it was all very foam-like.  After the boil, I transferred to a mason jar with total volume slightly more than 4 cups.  It was initially uniformly cloudy white, but then settled into the 3 layers previously observed.  The bottom layer was bigger than previously observed.

I used a baster to extract the middle layer (water) and tasted it - tasted like peanut butter, but not more so than previously.

There doesn't appear to be any major benefit of using double the amount of peanut butter, and the downside is that the greater amount of bottom sediment might mean less usable / uncloudy beer.

Previous post about peanut butter in water: Testing boiling peanut butter in water: results

Next post: Brewing a peanut butter porter - the wort

Monday, March 3, 2014

Hydrogen bonding in drugs

A member of my group, Patrick McCarren, worked on modeling the hydrogen bonds in some molecules at the Broad Institute that we screen as potential drugs.  It was part of a very nice paper which included a lot of solid experimental work:
http://pubs.acs.org/doi/abs/10.1021/jm500059t

It got a write up here:
http://wavefunction.fieldofscience.com/2014/02/hiding-hydrogen-bonding-groups-in-large.html

and here:
http://pipeline.corante.com/archives/2014/02/28/computational_nirvana.php


Tuesday, February 18, 2014

Testing boiling peanut butter in water: results

Following up on preparing to test boiling peanut butter in water, after letting the mixtures sit for a day, I tested them.  They looked very similar - they hadn't noticeably separated further.  The oil layer (top) was about the same thickness, same color, possibly less homogeneous.  The other two layers also appeared the same (thickness, color / cloudiness).

Monday, February 17, 2014

Bottling the carob porter

I bottled the carob porter (previous posts: initial brewracking into secondary) today.

Cleaning / sterilization

I washed everything with soap and water yesterday, I used a brush to scrub inside of bottles and auto-siphon.  I sterilized my equipment and the bottles using iodine solution, prepared by filling the bottling bucket with the hottest possible water. I added about ~3 splashes of iodine solution from the bottle until the the color of the solution was light orange.  Everything sat in solution at least 2 minutes, and then was allowed to drain / dry for several minutes.

Sunday, February 16, 2014

Testing boiling peanut butter in water: preparation

In preparation for making a peanut butter beer, I ran some small scale experiments boiling peanut butter in water, to mimic what will happen during the brew.  I had read the biggest concern was avoiding having the beer be oily, so last time I tried peanut butter flavored beer, I centrifuged the peanut butter for ~90 minutes, which separated the it pretty well into oil and dry solids.  I discarded the oil and boiled the solids in the wort.  After bottling (after a secondary fermentation), I tried the liquid at the bottom of the carboy and it had a very strong peanut butter flavor.  However, the bottled beer had no peanut butter flavor.  My guess is that since the beer I sampled had a lot of solids, but the bottled beer had none, the solids were the source of the flavor.  That presents two possible next steps:

  1. prepare the beer with the peanut butter with its oil to try to extract some amount of flavor and or oil into the beer mixture, then remove excess oil
  2. leave the peanut butter solids in the bottled beer, and like a hefewezein or wheat beer, serve with the sediment

Tuesday, February 11, 2014

Matlab spconvert function - undocumented "feature"

Matlab has a useful function for loading data that is in a sparse format - spconvert.  Basically, you create a file where each row contains the row, column, and data of the matrix you wish to load.  The first column is indicates the destination row, the second column indicates the destination column and the third column indicates the value at that row and column.  You load that into matlab (using, e.g., csvread):
sparse = csvread('mydata.csv');

example:
sparse = [1 1 2
2 1 3
2 2 5
3 3 7];

"sparse" is now have a N by 3 matrix, where N is the number of non-zero entries in your data.  With the command:
mat = spconvert(sparse)

yields:
2 0 0
3 5 0
0 0 7

Warning!!!! This doesn't appear to be documented!!! If you repeat a location in sparse, the value that appears in the result (mat) will be the sum of the entries in sparse.  For example, if sparse is modified to be:
sparse = [1 1 2
2 1 3
2 2 5
3 3 7
1 1 11];

then mat = spconvert(sparse) yields:
13 0 0
3 5 0
0 0 7

Note that the (1,1) entry of mat is 13, the sum of 2 + 11, the first and last rows of sparse.

Monday, February 10, 2014

Straightening the steering tube of my bianchi

Do not try this yourself, ever.  According to everyone I've talked to it is the most dangerous thing you can do, you will die a horrible, burning death if you try this.

My bianci is awesome.  It's a steel frame, red, I bought it from Stos & Alicia for $75 a few years ago.  I think they got it off of Craigslist.  It is a great commuter bike because it is rugged but goes fast - the frame actually fits me.  Unfortunately it is hard to get parts for it.  The rear axle broke awhile back and none of the bike shops had one or could get one.  I finally went to Harris Cyclery, and they had one that was close to the right size, so I bought it and a hack saw, made a rough measurement using the broken pieces of the old axle, and voila!  Back in the saddle.  This was after I partially rebuilt the rear wheel (replacing dead spokes, truing).

Not long after that, while I was riding along the Charles to work one morning, the front brake fell off, lodged in the front wheel, and I went flying over the handle bars.

Saturday, January 25, 2014

Follow up to Carob Porter - racking into secondary

Just a quick note - today I racked the Carob Porter beer from the primary fermenter into a secondary.  It's been about 3 weeks.  The beer was bitter but not spoiled, and was not sweet, so I'm hopeful the yeast got through all / most of the sugar.

There was a layer of material floating at the top, and of course a layer of muck at the bottom.  I suspect the layer of top material is what would normally get blown off during fermentation - this was a half batch, the carboy is only half full, and in a full batch a good amount of material is carried out through the airlock during the fermentation.  Because the top of the liquid was much further from the airlock, I suspect it is one reason it didn't happen this time (also the fermentation was not that vigorous).  I managed to avoid most of the material (top and bottom) during the transfer, although some did make it over.  Hopefully it will settle to the bottom during this stage.

Sunday, January 5, 2014

Brewing a chocolate ... whoops, carob ... porter. Crude heat capacity calculations...

I started a batch of homebrew today, aiming for a chocolate carob* porter.  My overall goal is to make a peanut butter porter, and possibly even a chocolate-peanut butter porter, but since I haven't brewed in a while I thought I'd start with an established recipe, and if that works try the peanut butter.

* turns out I used carob instead of chocolate...