Scientific Computing

Install LibSVM in Matlab, GNU Octave and Python

Matlab and Octave are popular for machine learning prototypes due to their easier to learn (vs. R) interface. Python via scikit-learn is also a top choice for machine learning. Here’s how to install LibSVM for Matlab and GNU Octave.

Prereqs:

apt install make git g++

Compile LibSVM

git clone https://github.com/cjlin1/libsvm

cd libsvm

make

Creates executables svm-train svm-predict svm-scale. Compile the Matlab/Octave and Python modules, for which the API is similar.

Compile LibSVM Matlab/Octave module

cd libsvm/matlab

Open Matlab or Octave, and from that internal Terminal, type (this uses make.m)

make

which creates a few .mex files. See the matlab/README for examples of using LibSVM from Matlab and Octave.

Compile LibSVM Python module

cd libsvm/python

make

See the python/README for examples of using LibSVM from Python.

Install PMTK3 in Matlab / GNU Octave

The authors estimate about 75% of PMTK3 is available from Octave, while Matlab support is comprehensive. PMTK3 has been in maintenance mode for a few years, as the world has moved on Python in significant numbers. Nonetheless, PMTK3 should not be neglected for easy access to a wide variety of machine learning methods.

Install PMTK3:

git clone https://github.com/probml/pmtk3

cd pmtk3

From Matlab or Octave:

initPmtk3

which downloads supplementary files (one-time). Run programs like demos/bigO.m

Losslessly trim in time videos with FFmpeg

Trim from time to end of video–discard beginning of video. In this examples, starting at 58 seconds.

ffmpeg -i in.mp4 -ss 00:00:58 -c copy out.avi

Trim from start to specified end time. In this example from 00:58 to 1:10.

ffmpeg -i in.mp4 -ss 00:00:58 -t 00:00:12 -c copy out.avi

Re-encode losslessly:

ffmpeg -i in.mp4 -ss 00:00:58 -t 00:00:12 -c:v ffv1 out.avi

Build POV-Ray

Install POV-Ray by:

apt install povray

or build POV-Ray from source

Example POV-Ray tutorial

#include "colors.inc"
background { color Cyan }
camera {
    location <0, 2, -3>
    look_at  <0, 1,  2>
}
sphere {
    <0, 1, 2>, 2
    texture {
        pigment { color Yellow }
    }
}
light_source { <2, 4, -3> color White}

POV-Ray can accomplish photorealistic rendering via raycasting.

POV-Ray example

Play video from Beamer LaTeX presentation PDF

To pop up your default video player upon click in Beamer LaTeX-generated PDF, use the LaTeX syntax

\href{run:myvideo.avi}{cool video}

You must use either

  • relative path (e.g. ../data/myvid.avi gfx/myvid.avi)
  • fully resolved absolute path (e.g. /home/joe/data/myvid.avi)

These will NOT work

  • ~
  • $HOME

LaTeX Beamer multi-column table of contents

A LaTeX Beamer presentation (slide deck) with a long table of contents as generated by

\tableofcontents

may run off screen.

Fix

add to LaTeX preamble (near top of main .tex file):

\usepackage{multicol}

Then the TOC slide will go over multiple columns. In this example Beamer slide, two column table of contents is specified:

\frame{
\begin{multicols}{2}
\tableofcontents
\end{multicols}
}

Ubuntu applications shortcuts

For Linux desktop environments programs show up in menus from:

  • /usr/share/applications
  • ~/.local/share/applications ← especially for WINE

Sometimes an application might not appear in the desktop menus because it doesn’t have a .desktop file in either of these locations. Try opening one of the .desktop files for a program that works, and saving as a new file, editing for a program you’d like to work the same way.

Reference