Three Things I Love About Python

For years I’ve been programming in MATLAB. Recently, I started programming learning to program in Python. You can read an article that I also wrote about things I dislike in Python (coming from MATLAB). But, there are a couple of things that I really love about Python in comparison to MATLAB.

Cost

Photo by luis gomes on Pexels.com

That’s right: it’s free. Coming from MATLAB, I would have to pay for packages that I wanted to use. But this is not so in Python.

Most prominently, I’ve had to learn some parallel programming. In MATLAB, there are some brief structural changes, pay the fee for the toolbox, and you’re in business. In Python, the software was freely installable via pip, learn to make the code adjustments (not necessarily easy), and you can see the results!

Structure/Syntax

I love the forced indentation of Python. There are many languages that have no defined structure: Python is not one of those. If the subordinate statements to the “if” structure aren’t aligned and indented properly, your code will not run.

I also love the use of the ‘:’ symbol.

Interesting Control Structures

One of the things I loved about MATLAB was the ability to do things in exceptionally short lines of code. As such, I love list comprehension.

“Pythonic” code is the statement of writing code in ways that are native to Python and friendly to the reader is another one of my favorites. That there is such a list of descriptions due to a culture/society around Python is fantastic. A really great site of examples is available at https://www.codementor.io/blog/pythonic-code-6yxqdoktzt.

Conclusion

I’m growing to love Python (in lieu of MATLAB). Is it perfect? Absolutely not. But it’s pretty good and it’s capacity continues to grow.

You should expect to see more articles about Python!

Church Energy Usage Recommendations

Intro

If you haven’t already read the previous blog entries, you should read

  1. Church Energy Improvements (Part One)
  2. Continued Church Energy Improvements (Part Two)
  3. Church HVAC Efficiency (Part Three)

These posts give a pretty clear picture of what it is that we’re up against.

The Broad Street Church of Christ has been undergoing quite a bit of energy analysis. Here are some more things to summarize what we’ve learned.

First, since we use such crazy amounts of electricity, we’re considered a commercial entity. That means, that the utility uses a percentage (95%) of our peak usage to determine our electrical demand . Found at a https://harris.lagrange-ga.org/utilitydocuments/Electric%20Commercial.pdf, is a discussion of how power demand is determined for our city.

Church Energy Usage Recommendations

In speaking with one very helpful individual, he pointed out that the best thing we can try to do is to lower our electrical usage during the summer and consequently our rate (based upon demand) will be reduced on the year. We used, on average, 10,475.2 kWh/per month! So, the concept of this style of conservation can help us out considerably.

There are a few things that an HVAC installer (who focuses his efforts on churches) told me.

  1. Seven-day thermostats. There is no need to heat/cool units for mid-week events/services (say Wednesday nights) all five nights of the traditional work week. This will dramatically decrease church energy usage.
  2. You need to cycle the air periodically. Running the units (with the fan on “auto”) to heat/cool to about 4 degrees difference than the “resting” temp will pull moisture out of the air. This is a must for churches in humid climates–like GA. In a study (I’ll find the link), relative humidity (in the summer) fell below 55% when you kept the air temp at greater than 80 degrees.

The below link is a Google Document spreadsheet. In it, I have identified each and every zone of the building. From there, I created a Saturday/Sunday schedule and a MTWThF schedule.

https://docs.google.com/spreadsheet/ccc?key=0AhL08JM3LoHsdGtYbk5KcXZCbThTcG1uaEpReGt4eGc&usp=sharing

Current rest points for the winter are 55 (gas heated spaces) and 58 (heat pump spaces). In the summer, those points are 85 degrees uniformly. I’ve recently read that many churches in the far northern U.S. advocate as low as 45 degrees. I’d have to have more validation before attempting it.

Conclusion

At this point, I would find three things helpful:

  1. Links to a journal that would publish work like this–Christian/church/religious entities concerned with maximizing energy of their facilities or just sustainability (in general).
  2. Commentary from knowledgeable individuals. By this, I mean individuals who actually advise churches on energy policies for a career.
  3. Links to studies that address exactly these types of issues.

Please your thoughts/comments below in the comments section!

Data Mining Links

I’m looking for data mining links–that is, links on data mining.  In particular, I’m looking for links for good books on the topic of data mining.  I’ve got a few to share.

I’ve had these links open for months in my browser.  I decided to write a post about them rather than have a browser collapse and lose them.  Here they are:

  1. http://www.ebooks-space.com/ebook/1049/Data-Mining-In-Time-Series-Databases.html
  2. http://free-pdf-ebook.com/2010/05/19/an-introduction-to-data-mining/
  3. http://www.mathworks.com/matlabcentral/newsreader/view_thread/242712
  4. http://www.amazon.com/s/ref=nb_ss_b/102-5272393-2668901?url=search-alias%3Dstripbooks&field-keywords=data+preparation&Go.x=0&Go.y=0&Go=Go
  5. http://www.amazon.com/Preparation-Mining-Kaufmann-Management-Systems/dp/1558605290/sr=8-1/qid=1167255496/ref=pd_bbs_sr_1/102-5272393-2668901?ie=UTF8&s=books
  6. http://www.amazon.com/Data-Mining-Practical-Techniques-Management/dp/0120884070/sr=1-5/qid=1167255699/ref=sr_1_5/102-5272393-2668901?ie=UTF8&s=books
  7. http://abbottanalytics.blogspot.com/

If you have any additional books that would be excellent for us in an undergraduate level course on data mining, please let me know if the comments below.

Datamining Links

I’ve had these links open for months in my browser.  I’m looking for a good series of texts for a Data Mining course.\

Enjoy!

http://www.ebooks-space.com/ebook/1049/Data-Mining-In-Time-Series-Databases.html

http://free-pdf-ebook.com/2010/05/19/an-introduction-to-data-mining/

http://www.mathworks.com/matlabcentral/newsreader/view_thread/242712

http://www.amazon.com/s/ref=nb_ss_b/102-5272393-2668901?url=search-alias%3Dstripbooks&field-keywords=data+preparation&Go.x=0&Go.y=0&Go=Go

http://www.amazon.com/Preparation-Mining-Kaufmann-Management-Systems/dp/1558605290/sr=8-1/qid=1167255496/ref=pd_bbs_sr_1/102-5272393-2668901?ie=UTF8&s=books

http://www.amazon.com/Data-Mining-Practical-Techniques-Management/dp/0120884070/sr=1-5/qid=1167255699/ref=sr_1_5/102-5272393-2668901?ie=UTF8&s=books

http://abbottanalytics.blogspot.com/

http://ineedfile.com/finance-matlab

Converting Ogg to MP3

Introduction

I had a dilemma where I left my voice recorder at my office while going to teach in another building.  I had to improvise.  What was I going to do?

Converting Ogg to MP3

With the use of a standard microphone-in port on a desktop computer and, with the boom mic plugged into that port, I knew I could record voice.  Further, afterwards, I downloaded Audacity.  Audacity took microphone input flawlessly and recorded at a frequency of 44100Hz and a rate of 16 kbs.  Audacity will also save to .ogg (and it did!).

Once back in the office on my Linux computer, I followed advice from the link http://liquidat.wordpress.com/2007/12/03/short-tip-convert-ogg-file-to-mp3/ and used a simplified version of the oggdecode command.  I simply used

oggdecode myfile.ogg

The oggdecode command exports to a .wav format natively.  I was then able to use the command

lame --preset phone myfile.wav newfilename.mp3

Now, I have exactly the file I wanted–smaller than both the original .ogg-file and the .wav-file.

Conclusion

Why did I go through all of this trouble?  I did it so I could upload podcasts for my students to the course LMS.  I was very glad that I learned to do this.

If you have any questions or comments, leave them below!

 

Drawing a line in LaTeX

I needed to draw a horizontal line in a presentation for a in-lecture “fill-in-the-blank”. I found the link http://timmurphy.org/2009/08/15/drawing-horizontal-lines-in-latex/. Basically, all you have to do is

\line(1,0){250}

(taken directly from the aforementioned site). I adjusted the length down to get desired line size.

Enjoy!

p.s. Thanks to the author (Tim Murphy) at http://timmurphy.org/2009/08/15/drawing-horizontal-lines-in-latex/.

OOoLaTeX

I often write about pieces of software that I enjoy. In the post http://wp.me/pg2mp-4, I wrote about my favorite Oo.org plugins. OOoLatex was of course one of those.

For those not in the know, OOoLatex is a plugin built for Impress that allows the user to input LaTeX syntax and (through the TeXLive compiler, I presume) generate images that will go in the presentation. The result is prettier than the formula editor and is easier to create (if you’re a LaTeX user).

The Sf.net project page link is found at http://ooolatex.sourceforge.net/.

Enjoy!

Openoffice Extensions That Increase Your Productivity

Introduction

I began using Openoffice.org (Oo.o) as a graduate student as Linux became more and more feasible for regular use. Today, this suite continues to blow me away and improve my daily productivity. Each and every release represents a steady increase in the usability and universality of the suite. Kudos are demanded for the developers.

However, what makes me happiest is the number of Openoffice extensions by which I can add new functionality. By the implementation of Openoffice extensions, I become more productive and therefore reduce the amount of my life consumed by work.

Openoffice Extensions

Available at http://extensions.services.openoffice.org is a long list of Openoffice extensions (some more usable than others). My favorites included:

  • PDF import functionality (now, no longer necessary)
  • the Google Docs extension (you can edit and upload Oo.o docs to Google Docs, seriously)
  • ooolatex-with this extension you can implement LaTeX formulas in both the presenter and the writer instead of the equation composer
  • Presentation Minimizer-reduces the size of the presentations
  • Presenter Console-gives more control over the presentation
  • writer2latex-just what you think, it converts writer files to .tex extension for compilation, and
  • The Sun Report Builder-gives Oo.o Base the graphical functionality required to make excellent reports

Conclusion

These are by no means the only, productivity-increasing plugins for Openoffice.org. But, for those who work in the sciences and academia, these can definitely make your life easier. Remember that productivity means greater time for other aspects of our lives.

As an aside, one might also consider examining the LibreOffice project which is a fork of the OO.org project. This project, at one point, had much better MS Office integration than its counterpart. Yet, I say “well done!” to the developers on both projects.

If you have plugins that you love, leave them below in the comments! I’d love to hear what you have to contribute.

A Bisection Method

The Bisection Method is perhaps the first of the root-finding methods because it works like our minds do. If we know a root exists in an interval [a,b], all we have to do is keep cutting the interval in half and look in the more appropriate half. How do we do that?

First, note that the bisection method relies upon functions

f:R->R.

This function must be continuous on [a,b]. Further, almost all bisection codes rely on the fact that f(a)*f(b)0 at x=a and x=b. We couldn’t verify the existence of roots. Functions such as g(x)=sin(x)+3 have no roots on any interval! Consequently, without further automation, we must check for f(a)*f(b)<0.The bisection method approximates the root atp_i=(a+b)/2.If f(a)*f(p_i)<0, then we pick b=p_i. Otherwise a=p_i. We continually shrink the interval until abs(b-a)< eps.

A version of the bisection method written for MATLAB or Octave is posted at bisect.m. This code requires a function given by handle and an interval [a,b]. Additional options include maximum iterations, tolerance on the root and tolerance on the function value.

I hope this is useful for coursework in basic numerical analysis classes or for basic root finding.