My Racket page: Project Euler problems 1..50 and a lot of Gamble probabilistic programming models

(I'm still a little embarrassed about my newbie question earlier, but nowadays I only focus on Racket and don't mix with other Lisps, except for Emacs Lisp occasionally. I still do newbie mistakes, but not very often that one. :-)).

I really like Racket, mostly for its extensive support of a lot of nice packages, e.g. math and Gamble. Perhaps my style is not the purest style, since I tend to prefer for loops over recursion for traditional loop stuff.

Here is my Racket page: My Racket page .
The programs are also at my GitHub repo: hakank/racket at master · hakank/hakank · GitHub (I try to keep this as updated as possible, but there might be some lag).

The page includes:

  • The first 50 Project Euler problems (https://projecteuler.net/ )
    Whenever I start learning a programming languages, this is one of the first things I do.
    Happily Racket's math packages includes a lot of nifty and fast functions which makes this one of the fastest runs, about 2.7s solving time for all problems. (See My Project Euler page for comparison with my other Project Euler programs. )

  • And then the Gamble probabilistic programming package, what a great tool!

    I know it's discontinued but it's so great to work with. The page contains about 380 different models, mostly small probability problems (since that is what I like to do with PPLs). Many of these are ports from my WebPPL models (My WebPPL page), and there are still about 100 models not ported yet.

    Some examples:

Working with Gamble is so fun so I have not yet explored the Racket language in full, so that is on my TODO list, as well as checking out some other interesting packages such as racklog, minikanren, csp, Rosette,

By the way, I'm a (retired) Swedish software developer. Nowadays I'm an Independent Researcher, mostly in Constraint Programming, logic programming, and Prolog. Here's my site: http://hakank.org/ .

6 Likes

I appreciated this post, even though I'm new to Racket and don't know many of the things you refer to.

I was curious about Gamble in particular, as I've been doing a bit of probability recently, but had to go click around a bit before getting to the main thing, so here's the link to the relevant book for anyone in the same boat:

https://rmculpepper.github.io/gamble/index.html

It looks nice! But maybe scribble just looks nice, hah. Did you go through the book, or just jump in to using Gamble? Was the fact it is discontinued relevant, or did everything work well?

I could conceivably use it to play with models of the problems I'll do if I continue with the probability book I have been investigating. It'd certainly be a good excuse to attempt some racketeering.

1 Like

I have written quite a few probabilistic programming language (PPL) programs before (e.g. in WebPPL, see my WebPPL page: My WebPPL page ) and started to port these to Gamble. Since I knew what I wanted to do, but didn't know the exact syntax, I just browsed the Gamble docs randomly, especially the "Probability Distributions" and "Samplers and Solvers" pages. Eventually, I've read the complete Gamble book, but not in sequel.

However, since I was used to a specific representation of the output (from WebPPL), I had to write quite a few helper functions, for example the main wrapper function show-marginals (defined in http://hakank.org/racket/gamble_utils.rkt) that shows the model output similar(ish) to WebPPL's output.

It's of course a pity that Gamble has been discontinued, but I've found very few things that didn't work as expected and that couldn't be fixed (worked around) somehow. That being said, an updated version of Gamble would probably contain different/faster sampler/solvers.

By the way, WebPPL is also discontinued, but it's still one of my favorite PPL, now together with Gamble.

A really great book for beginners in Probabilistic Programming is "Probabilistic Models of Cognition" http://probmods.org/, which happens to showcase WebPPL (and is written by the WebPPL creators).

2 Likes

Noted, bookmarked, and thank you for sharing your experiences - that book looks very interesting!

1 Like

Nice to see fellow Racket newbies with a view to a good scientific future for Racket! BTW, picat is still very high up my list of constraint languages to explore - I'm battling with CHR at the moment.

1 Like

Have you tested Racket's SMT constraint model package Rosette (The Rosette Guide )?

Looks fascinating, but it will be a while till I get round to it :slightly_smiling_face: