Welcome to my new site. I hope you find interesting tidbits from my work here. Old posts Old posts can be found at my old blog. New things will be posted here from now on. I have copied many posts from the old blog.
I’ve had a 500px account for some time, but I just decided to make an Instagram account. I did it mostly to enter the Denver Botanic Gardens Orchid Showcase Photo Contest, but I think it could be a fun way to share my interest in photography as well. I’ll be posting my favorite of favorite pictures at 500px, and then everything at Instagram. Hopefully, this means I’ll take more photos.
Mood tracking: first plots
For some time now, I’ve been using the app Daylio to track my mood. It allows me to rate my mood on a 5 point scale: awful, bad, meh, good, and rad. I can also put pictures, notes, or log what activities are related to that mood at the same time. It’s quite a nifty little app. I just decided to download the data and start examining it more critically. I hope to build a small set of tools to automatically process all the data and interpret conclusions.
Sliding puzzles: my beginning
I recently have become interested in sliding puzzles. You can read all about them on Wikipedia. In undergraduate AI, I was ask to implement a solver for the rush-hour game, a version of a sliding puzzle. I forgot all about it until recently when I was preparing an AI lesson to teach for Code Connects, a coding education non-profit. I stumbled upon the 8-puzzle. Difficulty of AI At first, it seemed pretty simple, and I thought an AI would do easy on it for bigger boards, but I was sorely mistaken.
Comparison of speed of np.sum in Cython
I was curious how much the overhead of np.sum impacted Cython code. That is, should you write your own sum method that loops or use np.sum? So, I wrote up a little test definition of the two approaches, as shown below: import numpy as np cimport numpy as np cpdef double sum_np(np.ndarray[double] a): return np.sum(a) cpdef double sum_loop(double[:] a) nogil: cdef size_t i, I cdef double total = 0.0 I = a.
Truncate to specified number of significant figures
It’s a simple request. You have a number, e.g. 1.25, and want to truncate it to say 2 significant figures. You specifically need to truncate instead of rounding, i.e. you need to get 1.2 instead of 1.3. How do you do that quickly in Python? Check out this code snippet: from math import log10, floor import decimal decimal.getcontext().rounding = decimal.ROUND_DOWN def truncate_sig(x, sig=2): x = float(x) # make sure it's a float or decimal throws an error if x == 0: # can't take log10(0) so just return 0 return 0 elif x <= 0: # if it's negative, determine sigfigs of positive and multiply by -1 return -1 * truncate_sig(np.