Summary: A Ruby/RMagick script of mine was failing with a variety of “Cannot allocate memory” errors. Adding a single line to the bottom of my thumbnail generation loop fixed this: img.destroy!.
Read More
The context: a GoDaddy VPS running FC7 (apparently, GoDaddy hasn’t updated their VPS distros in years).
The problem: The inability to use any Ruby Gems because the FC7 ruby and ruby-gems packages are years and years behind everything I’m trying to install. Also, RMagick is segfaulting.
More problems: I can download and compile Ruby 1.9 just fine, but when I try to install Ruby Gems 1.3.1, it overwrites the Ruby interpreter (what??). This problem is documented here, but I’m pretty sure I’d have to pull from the repository to grab the fix.
My solution: Install Ruby (make install). Install Ruby Gems (ruby setup.rb). Move the gem binary to where it belongs (mv /usr/local/bin/ruby /usr/local/bin/gem). Install Ruby again (make install). This appears to work.
I gotta get off that GoDaddy VPS.
Anything with user-submitted ratings can be sorted by those ratings. But what is the best way? The naive approach is to sort by average rating. Unfortunately, this would rate 5-stars from a single user as higher than 4.5-stars from 150 users.
This guy has an answer. In short, his recommendation is to take the lower bound of the 95% confidence interval, given by:
[latex size=”3”]\frac{\hat{p}+\frac{z^2{\alpha/2}}{2n} \pm z{\alpha/2}\sqrt{(\hat{p}(1-\hat{p}) + z^2{\alpha/2}/{4n})/n}}{1+z^2{\alpha/2}/n}[/latex]
where
- [latex]\hat{p}[/latex] is the observed fraction of positive ratings
- [latex]z_{\alpha/2}[/latex] is the [latex]1-\alpha/2[/latex] quantile of the standard normal distribution
- [latex]n[/latex] is the total number of ratings
Or, in Ruby:
require 'statistics2'def cilowerbound(pos, n, power) if n == 0 return 0 end z = Statistics2.pnormaldist(1-power/2) phat = 1.0pos/n (phat + zz/(2n) - z * Math.sqrt((phat(1-phat)+zz/(4n))/n))/(1+z*z/n) end
where
- pos is the number of positive rating
- n is the total number of ratings
- power refers to the statistical power (0.05 recommended)
Summary: Attached is a diff that allows Bio::FlatFileIndex to access BDB flatfile databases created by BioPerl’s Bio::DB::Flat. I have not changed the way BioRuby creates its databases, so this likely breaks access to BioRuby-created flatfile indices.
Read More