Adapted for v0.3 compatibility

Functions `numel` and `randi` are not supported by Julia's latest release (v0.3). Instead, `length` and `rand` should be used.