Installing Octave on Ubuntu 14.04


This post is more than 5 years old. While math doesn't age, code and operating systems do. Please use the code/ideas with caution and expect some issues due to the age of the content. I am keeping these posts up for archival purposes because I still find them useful for reference, even when they are out of date!

I'm taking Andrew Ng's machine learning class at coursera that started June 17, 2014. In the Silicon Valley tech world, this seems to be the online course that many people recommend for machine learning. The course is taught using Octave or Matlab . I'll use Octave because I'm on Ubuntu and Octave is a Gnu project.

I will also blog about the topics covered using Python because this is my language of choice. However, I will not poster answers to exercises. Instead I will discuss the method and how to implement, or use existing tools, in Python.

First, let's install Octave and gnuplot :

$ sudo apt-get install octave gnuplot

Accept all the suggestions (there are many) and let the installation complete. Starting Octave from the terminal should look something like this (I try out the first part of the Octave simple examples before exiting):

$ octave
GNU Octave, version 3.8.1
Copyright (C) 2014 John W. Eaton and others.
This is free software; see the source code for copying conditions.
FITNESS FOR A PARTICULAR PURPOSE. For details, type 'warranty'.

Octave was configured for "x86_64-pc-linux-gnu".

Additional information about Octave is available at

Please contribute if you find this software useful.
For more information, visit

Read to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> A = [ 1, 1, 2; 3, 5, 8; 13, 21, 34 ]
A =

1 1 2
3 5 8
13 21 34

octave:2> B = rand (3, 2);
octave:3> B
B =

0.225359 0.115306
0.548261 0.295556
0.166765 0.073095

octave:4> A * B
ans =

1.10715 0.55705
4.75150 2.40846
20.11315 10.19090

octave:5> exit

That's it, Octave (version 3.8.1) is ready to go. The class website has some Octave_ tutorials. I also found the wikibooks Octave tutorial , which seems to cover many of the basics in a concise way.