# RPI and SOS in Scheme, Python, and Elixir

Last spring, I played in a 3x3 basketball leage with 14 teams and only 6 regular-season games. The unbalanced schedule made me wonder if we would end up with wonky playoff seeding. I thought it would be fun to calculate the Rating Percentage Index (RPI) and Strength Of Schedule (SOS) for each team to assess discrepancies between W-L record and team rating. I was mostly following the R code for RPI in this post and the SOS calculations here. For comparison, I wrote code in Scheme (dataframe), Python (Polars), and Elixir (Explorer), which is also using Polars as the backend. All code and data are available here. Disclaimer: the Python and Elixir code works, but it may not be the most idiomatic or performant way to write that code.

# Proof of Kaprekar's constant in Scheme, Python, and Elixir

I thoroughly enjoyed this delightful post on Kaprekar's constant, which was new to me. Similar to the post author, I also like to use programming to understand mathematical concepts. I thought it would be a fun exercise to translate the example Ruby code to my favorite language, Scheme, and two other languages that I'm learning, Python and Elixir.

# Dataframe manipulation in Scheme

This is yet another post where I try out my `dataframe` library for Scheme (R6RS) on examples found in blog posts. This blog post demonstrates data manipulation with `dplyr` (R). I provide only the Scheme code and some commentary. You will have to click through to the original post to see how it compares to R.

# Comparing dataframe operations in Scheme, Python, and R

I recently came across this blog post that calls `pandas` (Python) "clunky" compared to the "silky smooth" `dplyr` (R). No objections from me. `dplyr` is my favorite R package. I thought it would fun to compare the relative clunkiness of my `dataframe` library for Scheme (R6RS) to `pandas` and `dplyr`. I will include the R and Python code here to save some clicking back and forth, but will mostly be commenting on the Scheme code.

# Exploratory data analysis in Elixir

I have been tinkering with lots of different programming languages (see here and here) over the last few years. Scheme is the only language so far that I have enjoyed enough to write a decent amount of code. Elixir first caught my eye back in April 2020, but I've only recently tried to write more than 'hello world' with it. So far, I think it is great and I'm excited to learn more. I haven't previously been a fan of code notebooks, but I think Livebook is amazing.

# Data transformation in Scheme

I have done some recent work on my `dataframe` library for Scheme (R6RS) and thought I would run through the examples in the Data Transformation chapter of R for Data Science (R4DS). In this post, I won't reproduce any of the R code and will provide limited commentary on the Scheme code (which is also available via this gist).

# From Python to NumPy: random walk example in R and Chez Scheme

As a learning exercise, I decided to translate examples from the book, From Python to NumPy, into R and Chez Scheme. This post describes the random walk example from Chapter 2. All of the code is in this repository so I will only highlight a few pieces of code below. For context, I am a long-time R programmer who only periodically pokes at Python and dabbles in Scheme for fun. Because performance is the primary motivation of vectorizing code with NumPy in Python, I will be loosely comparing timings between Python, R, and Chez Scheme. Take these timings with a large grain of salt. I don't know how comparable the different timings are.

# Visualizing Scheme library procedures with an interactive network graph in R

As a learning exercise, I wrote a `dataframe` library for Scheme (R6RS). Because I was learning Scheme while I wrote `dataframe`, I did not prioritize performance. However, as I've tried to use the `dataframe` library (exploratory data analysis, spam simulation, gapminder), I've encountered performance pitfalls that make `dataframe` largely unusable for datasets with more than a few thousand rows. I have a rough idea of where the bottlenecks are, but I thought it would be a useful to take a step back and visualize the `dataframe` procedures as a network graph.

# Stochastic population model in R, Rcpp, and Fortran

The stochastic logistic population model described in this blog post has become my default exercise when I'm exploring a new programming language (Racket, F#, Rust). I ended that Rust post by noting that I was interested in Rust as a modern alternative for scientific computing and thought it would be a good learning exercise to re-write small legacy Fortran programs in Rust. In the process of looking for Fortran programs to translate to Rust, though, I found myself becoming more interested in the idea of learning Fortran than Rust, particularly after learning about the efforts to improve the tooling around Fortran (e.g., here and here). So, here we are...exploring Fortran via the stochastic population model exercise.

# Analyzing gapminder dataset with base R and Scheme

I keep my eye out for blog posts illustrating data analysis tasks in R that I can use to test the functionality of my `chez-stats` and `dataframe` libraries for Scheme (R6RS). A post comparing `pandas` (Python) and `dplyr` (R) in a basic analysis of the gapminder dataset provides a nice little test case. In this post, I will also include base R code used to accomplish the same tasks as a contrast to both the Scheme code and the `dplyr` code from the other post.