Archive for February, 2010

Musical Gem of the Week #3

Posted in Humanities on February 24th, 2010 by Noldorin – 2 Comments

Johann Pachelbel’s ubiquitously well-known Canon in D major may have earned this German Baroque composer his reputation as a “one-hit wonder”, yet this is perhaps not wholly fair. While he was certainly dwarfed by the splendour of musicians such as Bach and Handel who followed in his footsteps, he nonetheless managed to produce several works that deserve their places in the repertoire of high-quality Baroque music. Regardless, I would have to say my favourite of them all is the Chaconne in F minor for organ. Although a fairly short piece (at least by later standards), it certainly demonstrated his mastery of the instrument, which while not perhaps as great as Handel’s, was certainly noteworthy.

Listen or Download Here

(Played in full Burghard Fischer.)

Side note: Although I suspect no-one has realised yet, I’ve evidently adopted more of a bi-weekly schedule for these posts. No excuses here, though given my track record in this respect I’m liable to continue as long as no-one comments! If any of you readers are lurking out there, do please let me know; saying that, my obsessional need to record my thoughts and opinions probably will likely keep me active enough.

Learning Formal Logic

Posted in Maths & Science on February 23rd, 2010 by Noldorin – 1 Comment

I have recently taken it upon myself to dig into the wonderful world of formal logic in mathematics. Starting off with propositional logic, and quickly moving on to predicate (first-order logic), it is already striking me as a highly interesting subject. (One that can surely get very complex, and is currently still an active area of research). Although I’ve known about the topic and vaguely what it concerns for some years now, I was only properly introduced to while reading Gödel, Escher, and Bach (an excellent read, though not perhaps as revealing or ground-breaking to someone with a bit of solid background in pure mathematics and/or AI).

Now to the point of my post:  I have recently found a marvellous resource on the subject of formal logic; this website provides a gentle yet thorough introduction to both propositional and predicate logic (among other things such as set theory and recursion), along with interactive exercises. Between spending a few hours over a couple of days reading through it and a bit of discussion with someone who knows the subject has given me a pretty firm grasp of the conepts and maths behind it – at least I’d like to think. I know (perhaps foolishly) plan to go on to learn about such crazy topics as higher-order logic, categorical logic, type theory, model theory, and so on. Finding such an elucidating resource for those might be rather more challenging, though I have a few books in hand that I may review if all turns out.

Gödel

Markov Chain Generator in .NET

Posted in Programming, Software on February 18th, 2010 by Noldorin – 2 Comments

As part of  my current IRC.NET project (an IRC client library for .NET 4.0), I decided to create as a sample project an IRC bot that implements a Markov text generator, one of the many applications of the Markov chain, a particularly concept in probability theory. I am going to assume here that you already know what a Markov chain is and have some idea of its potential applications.

Here is the relevant C# 3.0 source code from my sample project that contains all the functionality relating to Markov chains and Markov generation. A rather nieve implementation, I would freely admit, but a simple and effective one, I’d like to think.

MarkovChain class

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace MarkovChainTextBox
{
    // Represents a Markov chain of arbitrary length.
    [DebuggerDisplay("{this.nodes.Count} nodes")]
    public class MarkovChain<T>
    {
        private static readonly IEqualityComparer<T> comparer = EqualityComparer<T>.Default;

        private readonly Random random = new Random();

        private List<MarkovChainNode<T>> nodes;
        private ReadOnlyCollection<MarkovChainNode<T>> nodesReadOnly;

        public MarkovChain()
        {
            this.nodes = new List<MarkovChainNode<T>>();
            this.nodesReadOnly = new ReadOnlyCollection<MarkovChainNode<T>>(this.nodes);
        }

        public ReadOnlyCollection<MarkovChainNode<T>> Nodes
        {
            get { return nodesReadOnly; }
        }

        public IEnumerable<T> GenerateSequence()
        {
            var curNode = GetNode(default(T));
            while (true)
            {
                if (curNode.Links.Count == 0)
                    break;
                curNode = curNode.Links[random.Next(curNode.Links.Count)];
                if (curNode.Value == null)
                    break;
                yield return curNode.Value;
            }
        }

        public void Train(T fromValue, T toValue)
        {
            var fromNode = GetNode(fromValue);
            var toNode = GetNode(toValue);
            fromNode.AddLink(toNode);
        }

        private MarkovChainNode<T> GetNode(T value)
        {
            var node = this.nodes.SingleOrDefault(n => comparer.Equals(n.Value, value));
            if (node == null)
            {
                node = new MarkovChainNode<T>(value);
                this.nodes.Add(node);
            }
            return node;
        }
    }
}

MarkovChainNode class

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace MarkovChainTextBox
{
    // Represents a node within a Markov chain.
    [DebuggerDisplay("Value: {this.value == null ? \"(null)\" : this.value.ToString()}, {this.links.Count} links")]
    public class MarkovChainNode<T>
    {
        private T value;
        private List<MarkovChainNode<T>> links;
        private ReadOnlyCollection<MarkovChainNode<T>> linksReadOnly;

        public MarkovChainNode(T value)
            : this()
        {
            this.value = value;
        }

        public MarkovChainNode()
        {
            this.links = new List<MarkovChainNode<T>>();
            this.linksReadOnly = new ReadOnlyCollection<MarkovChainNode<T>>(this.links);
        }

        public T Value
        {
            get { return this.value; }
            set { this.value = value; }
        }

        public ReadOnlyCollection<MarkovChainNode<T>> Links
        {
            get { return linksReadOnly; }
        }

        public void AddLink(MarkovChainNode<T> toNode)
        {
            this.links.Add(toNode);
        }
    }
}

As usual, I am keen to hear any sort of feedback about what is a useful little piece of code. Undoubtedly, markov chains have a number of pretty interesting applications in science and the computer world, so it would be cool to hear if other people are using this for different purposes…

The Litany Against Fear

Posted in Personal, Philosophy on February 11th, 2010 by Noldorin – Be the first to comment

Reading Frank Herbert’s Dune was an experience that has likely influenced me in a number of ways, some quite subtly. For certain, however, it has stimulated a great deal of my own philosophical thought. The Dune universe, while on the surface highly esoteric in certain ways, has in my view astounding relevance in the present day with regards to such matters as politics, philosophy, and interest – to a degree not possessed by any other work of science fiction (and few others) I have encountered. Moreover, it is most often expressed so elegantly that one cannot help but interpret it in a profound way.

The quote I wish to share here is undoubtedly one of those that should be meaningful to any man or woman alive today. The so-called “Litany against Fear” is a passage of text that first appeared in Herbert’s original Dune novel near the start of the book (when Paul undergoes his test of “humanity” under the threat of a Gom Jabbar). Call this passage a litany, mantra, or what you will – to me it is something that has significance well beyond it words.

I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past I will turn the inner eye to see its path.
Where the fear has gone there will be nothing.
Only I will remain.

While I would not be inclined to say I use it in the same way the fictional Bene Gesserit do, it is nonetheless a surprisingly effective passage to recite in ones mind at various times. What is more, the Litany against Fear is not simply confined to combat feat; to me, it is equally effective to resist any other “overwhelming” emotion, be it anger, hatred, regret, or obsession. Perhaps “resist” is the wrong word here even; the way the Litany helps to overcome fear is somewhat less obvious and forceful, not to be easily expressed in words, I think.

Any regular readers, please excuse this brief diversion into emotional and philosophical. Juxtaposed with all my technical and scientific posts, it may not fit in very well, but alas, this blog has never had much cohesion and is rather a brain dump for me. And while I may be unique in this opinion, I actually find that discovering the ongoing variety of thoughts in someone’s mind is far more interesting than consuming formalised articles.

Musical Gem of the Week #2

Posted in Humanities on February 10th, 2010 by Noldorin – Be the first to comment

Continuing from my first post of the series, I will again be posting about another masterpiece from the Baroque era.

Again, not to give too much of a preamble, but this composition does merit a quick introduction. Concerto No. 8 from Antonio Vivaldi’s Opus 3 (known as L’Estro Armonico) is a piece somewhat overshadowed in the common repertoire by the concertos from The Four Seasons. In fact, in my opinion it is in several of Vivaldi’s other works that more rightly deserve their places at the pinnacle of Baroque music (most notably several of the concerti from L’Estro Armonico and his Gloria in D major). As it was, the great Bach himself took great inspiration from this set of concerti, transcribing several of them for other instruments – some accalade. (Funnily enough, “l’estro” means “the inspiration” in Italian.)

Apart from this particular concerto being a wonderful example of musical creativity and artistry, I think it is perhaps its enormous vivacity that sets it apart from the others. Full of energy, yet equally sophisticated – a defining mark of Italian Baroque music, in particular Vivaldi’s, in my view.

Listen or Download Here

1st Movement, Allegro

2nd Movement, Larghetto e spiritoso

3rd Movement, Allegro

This recording, by the Advent Chamber Orchestra, is as far as I know public domain, and pretty darn good given that. Anyway, enjoy.

Electronic Lecture Notes Revisited

Posted in Maths & Science, Personal, Software on February 3rd, 2010 by Noldorin – 2 Comments

As I promised, I have finally gotten around to evaluating the effectiveness of taking lecture notes using an Eee PC (a first model version, borrowed from a friend). I say evaluate, but I am effectively referring to one thing: the annoyance of typing mathematics in LaTeX on a keyboard less wide than my handspan. Although as a physicists student, this plan has turned out not to be the most effective, I would be inclined to think that many of the problems would be eliminated if you were just taking notes for a history lecture or such (pretty much any humanity for that matter, including law, as I’ve been told). Regardless, reST is at least a pretty nice format in which to write, and using doctutils to pdf-ify the notes is still the way forward, I would say. So to summarise, the quite horrible ineffiency (and concentration required) of typing was the main reason that led me to abandon the (initially very hopeful) endeavour by two weeks into term. I can’t be sure how much one of the newer Eee PC models would have helpd me – somewhat, but not hugely, I would think.

As it is, I am fortunate enough that all my lecturers have decided to hand out printed (and generally pretty complete) notes for the subjects this term. Me, being the lazy student I am, am finding it a good excuse to not bother with any notes for the current term. Saying that, at least it’s letting me focus more on actually understanding the (painfully opaque) material of the current courses, which is surely a good thing!

Well, at the least, I hope I have give some thoughts to anyone else considering a similar plan for lecture notes. It would be actually be quite satisfying to hear if there are any humanities students out there that have adopted the reST/PDF approach. Equally so, I would  be rather surprised if any science guys have managed to make the thing work with an Eee PC.