…so says the famous quote, my current mantra. This leads to my primary mission (or possibly, it would be more appropriate to call this my Prime Directive) is to code and get it all out. Brainstorm in code quicker and faster.
I have this extremely bad habit of writing 10 lines of code before shelling out the rest of the day learning how to improve these lines in R. Yes, I learn a lot through the process, but graduate students are responsible for more than just learning. Sometimes, there are those that actually have no interest in what I have learned but only my results.
This idea is nothing new to me, but this post is an attempt to enforce a turning of a new leaf. It was ridiculous for me to waste the previous hour intending to optimize TWO lines of code! I cannot and will not do this anymore. Those two lines of code were not important enough to waste that much time. Before my bedtime, my whiteboard may be plastered with a repetition of “I will refactor my code later and not now.” Unless the code is being published, procrastinated optimization is far better than procrastinated results.
Am I alone in this endeavor?
Posted in Code, R | 1 Comment »
Data frames in R are much like DataSets in SAS, SPSS, .NET, etc. Really, they are just spreadsheets that feel like a matrices. We can use these to look at numerical data along with any meta data or characteristics associated with the numbers though numbers are not required. From the R Documentation, “a data frame is a list of variables of the same length with unique row names”, and also it is “a matrix-like structure whose columns may be of differing types (numeric, logical, factor and character and so on)”.
Let’s take a look at an example. First, we start with generating a 3 x 3 identity matrix and assigning the matrix to the variable, mat.
mat = diag( 3 )
By typing mat, we can see the output.
[,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1
Next, we are going to convert this matrix to a data frame called mat_dataframe and output it.
mat_dataframe = data.frame( mat )
X1 X2 X3 1 1 0 0 2 0 1 0 3 0 0 1
Notice that the column names are X1, X2, and X3 and that the row names are 1, 2, and 3. Say we want to add more columns and rows to our data frame. Let’s first start by appending a row to the “mat_dataframe.” We do this with rbind.
mat_dataframe = rbind(mat_dataframe, c(2,2,2))
We have added a vector of twos to the next row of the data frame. Here’s what mat_dataframe looks like so far.
X1 X2 X3 1 1 0 0 2 0 1 0 3 0 0 1 4 2 2 2
Now, we should try appending 2 columns to the mat_dataframe using 2 different methods. The first line will create a new data frame from the original data frame and append a column called “City” with “Dallas” as the entry for each row. The second takes this data frame and adds another column called Color with entries blue and green.
mat_dataframe = data.frame( mat_dataframe, City="Dallas" ) mat_dataframe = cbind( mat_dataframe, Color=c( "blue", "green" ) )
Now, the mat_dataframe looks like this.
X1 X2 X3 City Color 1 1 0 0 Dallas blue 2 0 1 0 Dallas green 3 0 0 1 Dallas blue 4 2 2 2 Dallas green
Notice that once blue and green were both used, they were both repeated. Before we move on, let me mention a gotcha when adding columns. On the City column, I simply inserted Dallas for each row, but under the Color column, I added 2 different colors. What happens if we specify three values? Let’s try this with a new column called Country.
mat_dataframe = data.frame( mat_dataframe, Country=c( "USA", "Canada", "Mexico" ) )
We get the following error…
Error in data.frame(mat_dataframe, Country = c(“USA”, “Canada”, “Mexico”)) : arguments imply differing number of rows: 4, 3
A rule of thumb: make sure the number of values being assigned divides into the number of rows (or columns) of the data frame. If our data frame had 6 rows (or 9 or 12 or … ), we could have used the above code.
Our data frame is essentially a matrix with a couple of attached column vectors containing strings. This may not seem very useful at first, but it is a wonderful data structure, making some statistical methods among other things easier to use. Soon, I will post a basic ANOVA example using data frames.
Posted in Code, R, Statistics | No Comments »
Though I loved my old theme featuring one of my favorite books, The Hobbit, I needed more display options. The previous theme only showed my different posts and ignored categories among many other things.
My new theme is as shown…let me know if you like it.
It doesn’t handle my LaTeX plugin very well. I’ll have to work on that later.
Posted in Miscellaneous | No Comments »
Saturday night, the lights were out, and I was feeling my around the bed as I do every night. Something had changed just enough to throw off my plans. Our bedside stool that was not in its normal position, impeding my path; rather than going around it, I could not see it, and I attempted to plow through it.
In the process, I injured my toe — how much I do not know. I hate going to the doctor, and as much as my wife has encouraged me to do so, I have yet to do it.
Look at it, and tell me if I should go.

Posted in About Me | 4 Comments »
This is yet another forward that I did not wish to forward, but rather I thought I’d post it. Here it is…
Dear Diary,
For my birthday this year, my daughter (the dear) purchased a week of personal training at the local health club for me. Although I am still in great shape since being a high school football cheerleader 43 years ago, I decided it would be a good idea to go ahead and give it a try.
I called the club and made my reservations with a personal trainer named Belinda, who identified herself as a 26-year-old aerobics instructor and model for athletic clothing and swim wear.
My daughter seemed pleased with my enthusiasm to get started! The club encouraged me to keep a diary to chart my progress.
MONDAY:
Started my day at 6:00 a.m. Tough to get out of bed, but found it was well worth it when I arrived at the health club to find Belinda waiting for me. She is something of a Greek goddess – with blond hair, dancing eyes and a dazzling white smile. Woo Hoo!!
Belinda gave me a tour and showed me the machines. I enjoyed watching the skillful way in which she conducted her aerobics class after my workout today. Very inspiring!
Belinda was encouraging as I did my sit- ups, although my gut was already aching from holding it in the whole time she was around. This is going to be a FANTASTIC week!
TUESDAY:
I drank a whole pot of coffee, but I finally made it out the door. Belinda made me lie on my back and push a heavy iron bar into the air then she put weights on it! My legs were a little wobbly on the treadmill, but I made the full mile. Belinda’s rewarding smile made it all worthwhile. I feel GREAT! It’s a whole new life for me.
WEDNESDAY:
The only way I can brush my teeth is by laying the toothbrush on the counter and moving my mouth back and forth over it. I believe I have a hernia in both pectorals. Driving was OK as long as I didn’t try to steer or stop. I parked on top of a GEO in the club parking lot. Belinda was impatient with me, insisting that my screams bothered other club members. Her voice is a little too perky for that early in the morning and when she scolds, she gets this nasally whine that is VERY annoying.
My chest hurt when I got on the treadmill, so Belinda put me on the stair monster. Why would anyone invent a machine to simulate an activity rendered obsolete by elevators? Belinda told me it would help me get in shape and enjoy life. She said some other crap too.
THURSDAY:
Belinda was waiting for me with her vampire-like teeth exposed as her thin, cruel lips were pulled back in a full snarl. I couldn’t help being a half an hour late – it took me that long to tie my shoes.
Belinda took me to work out with dumbbells. When she was not looking, I ran and hid in the rest-room. She sent another skinny witch to find me. Then, as punishment, she put me on the rowing machine — which I sank.
FRIDAY:
I hate Belinda more than any human being has ever hated any other human being in the history of the world. Stupid, skinny, anemic, anorexic little cheerleader. If there was a part of my body I could move without unbearable pain, I would beat her with it. Belinda wanted me to work on my triceps. I don’t have any triceps! And if you don’t want dents in the floor, don’t hand me the freakin’ barbells or anything that weighs more than a sandwich.
The treadmill flung me off and I landed on a health and nutrition teacher. Why couldn’t it have been someone softer, like the drama coach or the choir director?
SATURDAY:
Belinda left a message on my answering machine in her grating, shrilly voice wondering why I did not show up today. Just hearing her voice made me want to smash the machine with my planner; however, I lacked the strength to even use the TV remote and ended up catching eleven straight hours of the Weather Channel.
SUNDAY:
I’m having the Church van pick me up for services today so I can go and thank GOD that this week is over. I will also pray that next year my daughter (the little brat) will choose a gift for me that is fun — like a root canal or a hysterectomy. I still say if God had wanted me to bend over, he would have sprinkled the floor with diamonds!!!
Posted in Funny | 1 Comment »
I must have had this epiphany several times in the last few years, but I had it again this evening while being introduced to the dark side. Many students are taught that
and that 0! is defined as 1. But is there some higher level mathematics in which this factorial idea is just a corollary as with most pre-graduate school mathematics. Well, there is! This is the epic Gamma function. It is defined as
.
If is a positive integer, then
.
Here is the main event. Suppose ; because
is a positive integer,
But then, notice that
.
Hence, our conclusion is that 0! = 1.
Posted in Math, Statistics | No Comments »
Normally, I do not forward emails along no matter how funny they are, and I thought this one required repeating…just not via email.
Dear Tech Support,
Last year I upgraded from Boyfriend 5.0 to Husband 1.0 and noticed a distinct slow down in overall system performance, particularly in the flower and jewelry applications, which operated flawlessly under Boyfriend 5.0. In addition, Husband 1.0 uninstalled many other valuable programs, such as Romance 9.5 and Personal Attention 6.5, and then installed undesirable programs such as NBA 5.0, NFL 3.0 and Golf Clubs 4.1. Conversation 8.0 no longer runs, and Housecleaning 2.6 simply crashes the system. Please note that I have tried running Nagging 5.3 to fix these problems, but to no avail.
What can I do?
Signed,
Desperate.
DEAR DESPERATE,
First, keep in mind, Boyfriend 5.0 is an Entertainment Package, while Husband 1.0 is an operating system. Please enter command: ithoughtyoulovedme.html and try to download Tears 6.2 and do not forget to install the Guilt 3.0 update. If that application works as designed, Husband 1.0 should then automatically run the applications Jewelry 2.0 and Flowers 3.5. However, remember, overuse of the above application can cause Husband 1.0 to default to Grumpy Silence 2.5, Happy Hour 7.0 or Beer 6.1. Please note that Beer 6.1 is a very bad program that will download the Farting and Snoring Loudly Beta.
Whatever you do, DO NOT under any circumstances install Mother-In-Law 1.0 (it runs a virus in the background that will eventually seize control of all your system resources.) In addition, please do not attempt to reinstall the Boyfriend 5.0;
program. These are unsupported applications and will crash Husband 1.0.
In summary, Husband 1.0 is a great program, but it does have limited memory and cannot learn new applications quickly. You might consider buying additional software to improve memory and performance. We recommend Cooking 3.0 and Hot Lingerie 7.7.
Good Luck!
Tech Support
Posted in Funny | 1 Comment »
My recent goal is to surround myself with things in my cubicle that will remind me of my work, so that when I inevitably become distracted, many “get back to work” signs act as a sometimes much needed slavedriver. Among these signs are charts of probability distributions and their properties, but first, I needed to find a good set of them — concise but all the information I need is presented. So, I Google’d for “lists of pdfs with properties,” forgetting momentarily that PDFs refer to more than just Probability Density (or Distribution) Functions. I changed my query to “probability distributions with properties” and was stunned to see Google’s following suggestion.
![]()
After being curious and clicking the 3rd of these links, I have manually turned on Google’s safe search feature for the first time.
Posted in Code, Statistics | No Comments »
Anthony turned me onto this new project called Project Euler. On the site, there are currently 202 computational math problems ranging from easy to extremely difficult. Several of the problems can be brute-forced in order to find a solution, but there are some that are just not possible to solve in this manner in this lifetime, and thus, clever methods are needed to solve the more difficult problems. As you may guess, I am becoming obsessed with this site; last night, I stayed up until 6:30am working on as many as I could. So far, I have solved 14 of them.
I was not too savvy with Python until now that I am restricting myself to using one and only one programming language for these problems; I have learned much about the language, and I’m quite impressed. It is always great to have mundane aspects of coding shot into oblivion because they really just are not needed anymore: well, maybe some will continue to believe C is necessary for all.
In the next couple of days, I am going to start uploading my code for these solutions; if anyone cares, maybe it will be a learning experience for us all. For the most part, I have the math know-how to solve these problems within the recommended minute, but I ask that any and all advice be given to improve my Python skills.
Posted in Code, Python | 1 Comment »
I have no idea why I am doing this because the last time I tried to go through with this, the lame programming references just got old. I deleted all of my posts except for one, and I’ve moved on and am no longer aspiring to be a code monkey. On August 16th, I will finally graduate with my B.S. in Mathematics from Baylor University, which will lead to my next venture – being a graduate student. Masochist? Probably. However, those cute little initials after my name when it’s all over might impress…the ladies. But there can be only one lady in my life. Her name is iPhone.
Yes, yes. Megan has come to terms with this, and she is willing to bear the bigamy for a bit. I cannot put this new toy down. Everything from Exchange support to a new way of interfacing with an iPod to my PhoneSaber app. This thing is just so shiny.
Posted in About Me | No Comments »


