In this post I will develop a simple C library to create and save an SVG (Scalable Vector Graphics) file, complete with a few examples of its use.
Continue reading
In this post I will develop a simple C library to create and save an SVG (Scalable Vector Graphics) file, complete with a few examples of its use.
Continue reading
In a previous post I implemented the Pearson Correlation Coefficient, a measure of how much one variable depends on another. The three sets of bivariate data I used for testing and demonstration are shown again below, along with their corresponding scatterplots. As you can see these scatterplots now have lines of best fit added, their gradients and heights being calculated using least-squares regression which is the subject of this article.
Continue reading
I recently wrote an article on Bubble Sort, more as an academic exercise than a piece of practical and usable code. At the bottom of the post I suggested that the C library's built-in qsort (Quicksort) function was the best option for sorting arrays in most situations.
However, there is more to using qsort than just throwing an array at a function: you need to provide your own comparator function, the implementation of which can be slightly fiddly if you are sorting anything other than primitive data types. In this article I'll start off with a simple int-sorting example, and then go on to sort an array of structs, firstly by an int and then by a string.
Continue reading
I am sticking my neck out here by implementing the notorious Bubble Sort in C. There are many sorting algorithms and even more variations on a theme, but the bubble sort is probably the best known. It's simple to understand and the process can be illustrated with some cute animations and even Hungarian folk dancing!
Continue reading
For this project I will write a JavaScript Widget which uses SVG to display numerical values on a web page in a seven segment display style.
Continue reading
Correlation is the process of quantifying the relationship between two sets of values and in this post I will be writing code in C to calculate possibly the best-known type of correlation - the Pearson Correlation Coefficient.
Continue reading
The ncurses library provides a range of functionalities for writing console applications which go beyond simply printing text, but without the complexity of writing a full GUI application. To me the most useful things ncurses provides is moving the cursor (and therefore print position) around the console, and printing with various text and background colours.
In this post I will introduce those two abilities but ncurses can do a lot more. If you want to look into the topic further I recommend Dan Gookin's book on the subject.
Continue reading
Today I'll write an implementation in C of Zeller's Congruence, a simple and elegant little formula to carry out the seemingly complex task of calculating the day of the week (Monday, Tuesday etc.) from a date.
Continue reading