CodePlea
Random thoughts on programming
06 Jan 2017

Incomplete Beta Function in C

The Incomplete Beta function, or regularized incomplete beta function, seems to be one of those functions that should be built into the standard libraries, but is conspicuously missing. It shows up all over the place in statistics. It's crucial to Student's t distribution, which is likely the second most important distribution in statistics after the Gaussian distribution.

I couldn't find an open-source implementation to fit my exact needs, so I'm going to give simple C code to compute it.

If you're just looking for code, check out the Github repo. If you want to learn how it works, keep reading.

Read the rest of Incomplete Beta Function in C

22 Dec 2016

GoAccess, Analytics, and PHP

GoAccess is an excellent open source web log analyzer. It makes nice, fancy charts and such:

GoAccess has several modes of running, including outputting HTML, or severing HTML live with its built-in webserver. I knew I wanted to use GoAccess to analyze my server logs, but I wasn't sure what the best way to use it was.

Read the rest of GoAccess, Analytics, and PHP

19 Dec 2016

Technical Analysis Library

I recently released a technical analysis library called Tulip Indicators under the LGPL license. If you need to do technical analysis, I think it's the best library out there now.

I also released a companion project called Tulip Cell which provides the functions to Excel spreadsheets via an add-in.

And finally, I'm working on a full featured charting program that I plan to release soon: Tulip Charts.

30 Nov 2016

Interpolating in a Triangle

Let's say we have a triangle. Maybe something like this:

Furthermore, let's say that each vertex (corner) has an associated value of some sort. For example: assume each vertex has an associated color. Perhaps we have:

Read the rest of Interpolating in a Triangle

23 Aug 2016

Exponentiation Associativity and Standard Math Notation

Someone recently told me that TinyExpr (my math expression evaluation library) had several bugs, mostly related to the precedence and associativity of the exponentiation operator. It turned out that they thought that math notation was more standardized than it actually is.

I made TinyExpr to be used in a spreadsheet-like program. Therefore, I tried to make it somewhat compatible with spreadsheets. This makes for behavior that may surprise some people. For example, TinyExpr evaluates multiple exponentiation from left-to-right by default. This behaviour is clearly documented in the Readme and can be changed with a compile-time flag.

I thought it'd be nice to do a survey of common computer languages and tools and see how they handle exponentiation precedence and associativity.

Read the rest of Exponentiation Associativity and Standard Math Notation

18 Mar 2016

Genann - Neural Network Library

I've made a simple neural network library in ANSI C called Genann. I released it as open-source on github recently. You can find it here.

A primary design goal of Genann was to be both complete and minimal. I'm happy with how close I've come to that goal. Genann implements the feed-forward algorithm, backpropagation, and not much else. It's not opinionated about how you store your data or about how you do training. It is contained in just a single C source file and header file.

Genann is also very easy to use. For example, creating a network with 2 inputs, 3 hidden neurons, and 2 outputs is as easy as:

/* inputs, hidden layers, neurons per hidden layer, outputs. */
genann *ann = genann_init(2, 1, 3, 2);

Read the rest of Genann - Neural Network Library

23 Feb 2016

Apple and the FBI

The FBI has gotten a court order demanding that Apple help unlock a San Bernardino shooter's work phone, an iPhone 5C.

This has been in the news everywhere for days, and I'm already sick of it, so I'm going to keep this short.

Almost everyone has read Apple's public response, but nobody I've talked to has read the actual court order itself. You're doing yourself a disservice if you don't read the actual court order for yourself. It's three pages, and it's much more precise than Apple's response or anything you'll read in the news.

From the order, we see that the government is asking Apple to do three things:

Read the rest of Apple and the FBI

11 Feb 2016

Succinct Code

I like simple things. It should be self-evident - I recently ditched WordPress for a hundred lines of PHP and flat-files. I'm much happier for it.

I used to write a lot of C++ code, but for the last several years I've completely eschewed it in favor of C. I can't ever see myself ever going back to C++, as I feel like C is a better language, and it's much easier to keep a large project nice and neat using it. C++ code has a tendency to grew crufty almost from the start. C++ has more abstractions, and although all abstracts are leaky, I think C++ lends itself to creating especially leaky abstractions. C++ makes it much easier to build yourself into a corner compared to C.

Anyway, a few days ago I witnessed an exchange on Stack Overflow that I thought was interesting. It pretty well illustrated some of the differences I find between C and C++ code. And also showcased some of the problems I have with Stack Overflow in general.

Read the rest of Succinct Code

For older articles, please see the archive.