The Problem "Motif finding is a problem of finding common substrings of specified length in a set of strings. In bioinformatics, this is useful for finding transcription binding sites" (recap here). The problem is succinctly stated on Rosalind. Given a set of strings DNA of size t, find "most common" substrings of length k. "Most common" means, that substrings … Continue reading Motif Finding with Gibbs Sampling (F#)
Category: F#
Modelling Stochastically Independent Processes with F# Computation Expressions: Part 1
The idea for doing this is not new. There is an excellent series of posts closely tracing an article on applications of functional programming to probability. A colleague of mine has recently called my attention to his own post of two years ago, where he describes a monad that models stochastically independent events in Clojure. … Continue reading Modelling Stochastically Independent Processes with F# Computation Expressions: Part 1
Generating Permutations: Clojure or F#: Part 2
Marching on from the last post. Lazy Sequences This is my favorite feature ever. If I want to generate just a few of 10! (nobody even knows how much that is) permutations, I could: provided, the function is defined (as described in the first post): Here I am not sure which language I like more. … Continue reading Generating Permutations: Clojure or F#: Part 2
Generating Permutations: Clojure or F#: Part 1
The Alogirthm Recently, I have entered a brave (new?) world of Clojure and was looking for a small project to take it for a ride. I stopped on a popular/interesting enough little problem, that subsumed a certain interview question which I was once unfortunate enough to stumble through with half my brain tied behind my … Continue reading Generating Permutations: Clojure or F#: Part 1
Computing Self-Organizing Maps in a Massively Parallel Way with CUDA. Part 2: Algorithms
In the previous post I spoke briefly about motivations for implementing self-organizing maps in F# using GPU with CUDA. I have finally been able to outperform a single threaded C++ implementation by a factor of about 1.5. This is quite modest, but on the other hand rather impressive since we started out by being 60 … Continue reading Computing Self-Organizing Maps in a Massively Parallel Way with CUDA. Part 2: Algorithms
Computing Self-Organizing Maps in a Massively Parallel Way with CUDA. Part 1: F#
By 2017, it is expected that GPUs will no longer be an external accelerator to a CPU; instead, CPUs and GPUs will be integrated on the same die with a unified memory architecture. Such a system eliminates some of accelerator architectures’ historical challenges, including requiring the programmer to manage multiple memory spaces, suffering from bandwidth … Continue reading Computing Self-Organizing Maps in a Massively Parallel Way with CUDA. Part 1: F#
F# vs C#. Fold and Aggregate
Suppose you need to write a script that finds n files, all called based on some pattern, say "c:\temp\my_file_x.txt", where "x" is replaced by a range of numbers [1..30] for instance, reads the content of these files and glues them together. Suppose also that the files are very small, so you can keep them in … Continue reading F# vs C#. Fold and Aggregate
Disposable Objects with Computation Expressions
The last post contains the description of a sqlMonad. It also happens to contain a silly and obvious (aren't they all in hindsight) bug. The bug is in implementing the containing CmdSqlBuilder with the IDisposable. While the intent was good (the class wraps resources that should be promptly disposed of - SqlCommand and SqlConnection): there … Continue reading Disposable Objects with Computation Expressions
Exploring Monadic Landscape: Sql Command Computation Expression
Most of the developers have dealt with calling SQL server stored procedures from their applications at least once or twice. In my last project, where intense data mining is done on the SQL side, this is basically all I am doing. There is always a desire to wrap and abstract the ever-repetitive code to get … Continue reading Exploring Monadic Landscape: Sql Command Computation Expression
Retry Monad: An Implementation
One application that seems quite intuitively to be a good case for "monadization" is that of retrying a function call upon an exception that is thrown while executing it. This may be needed for inherently unreliable operations, dependent on a network connection, for example. Discussions of this can be easily found. Here is one on … Continue reading Retry Monad: An Implementation