Thursday 16 August 2018

Linear programming in R

Linear programming is a technique to solve optimization problems whose constraints and outcome are represented by linear relationships.

aaa

Simply put, linear programming allows to solve problems of the following kind:

  • Maximize/minimize $\hat C^T \hat X$
  • Under the constraint $\hat A \hat X \leq \hat B$
  • And the constraint $\hat X \geq 0$

Automate your garden lights DIY style: getting practical!

This post is a follow up of this project.

After a lot of fiddling around, I finally built up the circuit for automating the turn on and off of my garden lights. It was about time wasn’it? Yeah, I know, it took me some time, but it was worth it since I think the end result is particularly nice and I enjoyed the process of building the circuit.

Goals of this project

The objectives of this DIY project are the following:

  1. Automate the turn on and off of garden lights: 4 LED lights powered from a battery which is recharged every day through an appropriately sized solar panel. The lights should turn on in the evening and turn off in the morning. Ideally turn on and turn off should be adjustable with ambient light.
  2. Improve my basic knowledge on how to design a proper circuit, a PCB, source components and debug analog circuitry.
  3. Keep the project relatively cheap.

The circuit in LTSpice

Below you can find a picture of the circuit simulated in LTSpice with all my notes following testing and a close up of the circuit.

Image 2

Image 3


Monday 13 August 2018

PCA revisited: using principal components for classification of faces

This is a short post following the previous one (PCA revisited).

In this post I’m going to apply PCA to a toy problem: the classification of faces. Again I’ll be working on the Olivetti faces dataset. Please visit the previous post PCA revisited to read how to download it.

The goal of this post is to fit a simple classification model to predict, given an image, the label to which it belongs. I’m goint to fit two support vector machine models and then compare their accuracy.

The

  1. The first model uses as input data the raw (scaled) pixels (all 4096 of them). Let’s call this model “the data model”.
  2. The second model uses as input data only some principal components. Let’s call this model “the PCA model”.


Sunday 12 August 2018

PCA revisited

Principal component analysis (PCA) is a dimensionality reduction technique which might come handy when building a predictive model or in the exploratory phase of your data analysis. It is often the case that when it is most handy you might have forgot it exists but let’s neglect this aspect for now ;)

eig2

I decided to write this post mainly for two reasons:

  1. I had to make order in my mind about the terminology used and complain about a few things.
  2. I wanted to try to use PCA in a meaningful example.

Friday 10 August 2018

IV characteristics of diodes

This week I finally got to play around a little with some electronic components I ordered and test them before using them on side projects. My goal was to find the IV curve of a 3V 0.5W zener diode I need to use on a project. Since I had all the instruments set up, as a bonus I decided to find the IV curve of a blue LED as well.

Test circuit and instruments setup.

The test circuit I used for the measurements is the following

Image 1

Sunday 4 March 2018

Calculating the DFT in C++

When you learn about the Fourier transform and what it can show you about a signal, you immediately start thinking about its possible applications. The Fourier transform, however, deals with continuous time signals while, in practice, computers deal with discrete time signals (i.e. a sampled version of the original continuous time signal). When it comes to discrete time signal, you can calculate a discrete Fourier transform to get the frequency content of the signal.

Figure_2