Git Product home page Git Product logo

lt-rs's Introduction

lt-rs

This is an implementation of a Luby Transform code in Rust, more or less a straight port from my Python project.

See D.J.C, MacKay, 'Information theory, inference, and learning algorithms. Cambridge University Press, 2003 for reference on the algorithms.

Encoding

The encoding algorithm follows the given spec, so no innovations there. A few optimizations are made however. First, the CDF of the degree distribution, M(d), is precomputed for all degrees d = 1, ..., K. This CDF is represented as an array mapping index d => M(d), so sampling from the degree distribution mu(d) becomes a linear search through the CDF array looking for the bucket our random number on [0, 1) landed in. This random number is generated as specified using the linear congruential generator.

Second, the integer representation of all blocks is held in RAM for maximum speed in block sample generation. This is a limitation on the size of the file practically encoded on most computers, but this decision does not reach far into other parts of the design, and it can be easily addressed if necessary for better memory scalability.

extern crate lt;

use std::io::{self, Write};
use std::fs::File;
use lt::encode::LTEncoder;
use lt::sampler::LTBlockSamplerParams;

// Get standard out
let stdout = io::stdout();
let mut handle = stdout.lock();

// Open file to transmit
let mut f = try!(File::open("foo.txt"));

// Build encoder with default parameters to stream file in 100 chunks
let num_blocks = 100;
let params = LTBlockSamplerParams::new(num_blocks);
let encoder = LTEncoder::(params, &mut f);

// Write each block to standard out
for block in encoder {
    try!(handle.write(block.encode()));
}

Decoding

The decoder reads the header, then the body, of each incoming block and conducts all possible steps in the belief propagation algorithm on a representation of the source node/check node graph that become possible given the new check node. This is done using an online algorithm, which computes the appropriate messages incrementally and passes them eagerly as the value of source nodes is resolved. Thus, the decoder will finish decoding once it has read only as many blocks is necessary in the stream to decode the file, and it seems to scale well as the file size, and block size increase.

// TODO:

Progress:

  • Sampler completed
  • TODO: encoder/decoder APIs
  • TODO: executables

lt-rs's People

Contributors

anrosent avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

lt-rs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.