Sorry, the page you requested was not found. Really.

  • The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Monday, 09 November 2009

  • Bug?

    I discovered today, interestingly enough, that the exponentiation operator ("^") in the TI-83/84+ calculator series is actually left-associative: the expression a^b^c^d in fact evaluates to (((a^b)^c)^d), or abcd.  This is also the case with the older TI-36X II scientific calculator.

    Ordinarily, one would expect the operator to be right-associative: a^b^c^d evaluates to (a^(b^(c^d))), or abcd, in common programming languages.

    IMHO, this discrepancy could be considered a bug, but apparently the behavior has always varied from model to model.

    Still, a part of me is left wondering how that little detail managed to escape my attention for several years.

Thursday, 22 October 2009

  • Troy and B.S. expertise go hand in hand

    I am inspired by this wise xkcd comic strip.
    Troy's Heuristic for English Language Survival:  "In regards to literary criticism, smoothly executed B.S. may be considered sufficiently indistinguishable from the real deal -- at least for the purpose of finishing that darn essay in the wee hours of the morning."
    (To an extent, this is the humanities equivalent of POGE.)

Thursday, 03 September 2009

  • Probability Sampling

    The homework today for AP Statistics was to toss a coin a hundred times and then record the result.  Hmm ... what busy work (for a computer).
    #!/usr/bin/perl -w
    # Usage: ./$0 $sample_size $event_name $probability [$
    event_name $probability ..]
    use strict;

    my @tmp = @ARGV;
    die "Not enough arguments" if scalar(@tmp) < 3;
    my $total = shift @tmp;
    my %
    events = @tmp;
    my $sum = 0;
    for (values %
    events) {
    $sum += $_;
    }
    die "Sum of probabilities $sum != 1" unless $sum == 1;

    my @keys = sort keys(%events);
    for(my $count = 1; $count <= $total; $count++) {
    my $result = rand;
    my $lower = 0;
    my $name = undef;
    foreach (@keys) {
    my $upper = $lower +
    $events{$_};
    if($lower <= $result && $result < $upper) {
    $name = $_;
    last;
    }
    else {
    $lower = $upper;
    }
    }
    die "Out of range" unless defined $name;
    print "${count}: ${name}\n";
    }
    exit 0;

    In all: ./randsamp 100 heads 0.5 tails 0.5
    The Perl script can work with a variable number of arguments, assuming that the first denotes the sample size and the rest are pairs of event names and probabilities.  Of course, the sum of the probabilities must exactly equal 1 or else the script dies.
    Remember to adjust the shebang line to point to the path of your Perl installation.

Saturday, 23 May 2009

Friday, 22 May 2009

Saturday, 09 May 2009

Thursday, 30 April 2009

Wednesday, 29 April 2009

  • HowTo: SoX Installation

    HowTo: Compiling SoX with read/write MP3 support in Ubuntu

    SoX describes itself as the "Swiss Army knife of sound processing programs," a well-deserved title given the amount of functionality outlined in the sox(1) man page - one can say it's the command-line version of Audacity.

    Due to patent issues and the typical legal mess, SoX binaries are distributed without MP3 support to avoid licensing fees  (I would prefer an unencumered open format such as Ogg Vorbis, but MP3 remains too common to ignore).  SoX can be given MP3 support, however, be recompiling it to use a third-party library such as LAME.

    Instructions here are specific to Ubuntu (8.10+) but may be adapted for Debian or any other distro that uses APT.
    1. Install packages required for the build environment (ensure that 'multiverse' and 'restricted' repositories are enabled in /etc/apt/sources.list).
      Note that, in Ubuntu 7.10 and 8.04, LAME development libraries are provided by liblame-dev instead of libmp3lame-dev.

      sudo apt-get install build-essentials fakeroot libmp3lame-dev
      sudo apt-get build-dep sox


    2. Retrieve and unpack SoX sources into a clean directory.

      mkdir sox
      cd sox
      apt-get source sox
      dpkg-source -x sox_*.dsc
      cd sox-*.*.*


    3. Remove the '--disable-lame' compiler flag; either use sed to automate the task or manually edit sox-*.*.*/debian/rules with a text editor.

      sed -i~ 's/--disable-lame//g' debian/rules

    4. Build the package.

      dpkg-buildpackage -b

      You should be able to see
      checking lame/lame.h usability... yes
      checking lame/lame.h presence... yes
      checking for lame/lame.h... yes
      checking for lame_init in -lmp3lame... yes
      <snip>
      LAME MP3 writer................... yes
      echoed in the terminal, although it is recommended you redirect stdout to a log file because the messages will likely escape the scrollback buffer before there is a chance to pause and read.
    5. The build will provide all SoX-related packages, but only certain local ones are needed to replace the repository versions.

      cd ..
      sudo dpkg -i sox_*.deb libsox-fmt-mp3_*.deb

    If all proceeds well, sox -h should give something like
    SUPPORTED FILE FORMATS: 8svx aif aifc aiff aiffc al alsa ao au auto avi avr caf cdda cdr cvs cvsd dat dvms fap ffmpeg flac fssd gsm hcom ima ircam la lpc lpc10 lu m3u m4a mat mat4 mat5 maud mp2 mp3 mp4 mpg nist nul null ogg oss ossdsp paf pls prc pvf raw s1 s2 s3 s4 sb sd2 sds sf sl smp snd sndfile sndt sou sph sw txw u1 u2 u3 u4 ub ul uw vms voc vorbis vox w64 wav wavpcm wmv wve xa xi
    Support for extra formats can be obtained through the libsox-fmt-all package.


    HowTo: Recompiling the latest SoX sources

    I found myself desiring the "norm" effect, but, unfortunately, the feature was introduced in version 14.1.0, while the 8.10 repository is stuck at 14.0.1.  In these cases, it becomes necessary to recompile the latest sources.
    1. Download and unpack the latest stable SoX sources for GNU/Linux (currently 14.2.0).  For expediency, wget is used here, but a regular web browser suffices.

      wget http://superb-west.dl.sourceforge.net/sourceforge/sox/sox-14.2.0.tar.gz
      tar -xvzf sox-14.2.0.tar.gz


    2. Set up the build environment.

      sudo apt-get install build-essentials fakeroot checkinstall libmp3lame-dev
      sudo apt-get build-dep sox


      Note that libmp3lame-dev is necessary for MP3 support through LAME, which is not automatically included among the SoX build dependencies due to MP3 patent/licensing issues.
      For Ubuntu 7.10 and 8.04, LAME development headers and libraries are provided by liblame-dev instead.
    3. Compiling involves the same standard procedure...

      cd sox-14.2.0
      ./configure
      make


    4. Due to some strange linking situation in which shared libraries were not detected correctly, the links need to be repaired after installing or SoX will not run.  (This took me a while to figure out.)

      sudo make install
      # Add /usr/local/lib to end of the include paths
      sed -i~ '$s/$/& \/usr\/local\/lib/' /etc/ld.so.conf
      sudo /sbin/ldconfig


    5. For easier uninstallation, checkinstall can create a deb package so APT can keep track of the installed files.

      sudo checkinstall

      Note that SoX is produced as a single package, rather than as multiple packages by repository conventions.
    Download for x64: sox_14.2.0-1_amd64.deb

Monday, 27 April 2009

A0u

  • Visit A0u's Xanga Site
    • Name: A0u
    • Gender: Male
    • Member Since: 8/21/2007
Don't worry - your calendar is here… to see it in action just click "Save" above and refresh the page.