GithubHelp home page GithubHelp logo

zeno's Introduction

Zeno -- a collection of helper functions for symbolic computations in Mathematica

Purpose of the project

In my recent research, I found that I often have to manipulate large symbolic expressions. Sometimes these equations are even hard to copy by hand on paper. Using Mathematica helped a lot. It provides many powerful features for manipulate symbolic expressions--when I do not know how to transform an expression through programming, at least I can copy-paste it and change it manually.

Zeno is a collection of helper functions that I wrote the past few months. Usually they are just wrappers for one-line codes. But I gradually learned to write them in better and more conciser ways, thanks to many helps that I got from mathematica.stackexchange.com. Hopefully these will also be helpful for others. At least by checking the code, you will see how to do certain things in Mathematica.

Zeno currently contains these packages:

  • Zeno.m -- helper functions for manipulating symbolic expressions.
  • ChernoffBound.m -- concentration inequalities.
  • CalcMoment.m -- formulas for calculating moments of random variables.

(The project is named after the accent Greek philosopher Zeno of Citium.)

Usage

Currently these packages do not have dependency. So you can simply download a package, say CalcMoment.m, in the same folder as your Mathematica notebook and load it by

SetDirectory[NotebookDirectory[]];
Needs["CalcMoment`"]

You can also put it in FileNameJoin@{$UserBaseDirectory, "Applications"} and then load it in your notebook by

Needs["CalcMoment`"]

To see available functions, type

?CalcMoment`*

Check this test notebook for examples of how to use these packages.

ChernoffBound.m -- Chernoff's bounds

Chernoff's bounds are some concentration inequalities widely used in probabilistic combinatorics. ProbChopper.m includes several versions of Chernoff's bounds for binomial distributions. To see all available inequalities available, type

ChernoffPrintAll[]

The proofs of these inequalities can be found in

  1. Michael Molloy and Bruce Reed, Graph Coloring and Probabilistic Methods, Springer Science & Business Media, 29 Jun 2013.

  2. Michael Mitzenmacher, Eli Upfal, Probability and Computing: Randomized Algorithms and Probabilistic Analysis, Cambridge University Press, 31 Jan 2005.

  3. Noga Alon, Joel H. Spencer, The Probabilistic Method, 2nd ed., John Wiley & Sons, 5 Apr 2004.

  4. Wikipedia -- Chernoff Bound

CalcMoment.m -- Truncated Moments

Given a random variable Y, sometimes we want to compute the expectation of Y[Y < a], where [P]=1 if the P and true and [P]=0 if P is false. (The notation is called Iverson Bracket.)

In Patrice, it can be convenient to write E(Y[Y < a]) in terms of the left and right tails of $Y$. These are two function TruncatedMoment and TruncatedExpMoment contained in CalcMoment.m which does this. You can load it and try it in a Mathematica notebook like this

SetDirectory[NotebookDirectory[]];
Get["CalcMoment`"]

gdist = GammaDistribution[3, 7]
gtest = TruncatedMoment[gdist, p, a] == TruncatedMoment[gdist, p, a, MomentForm -> "Left"] == TruncatedMoment[gdist, p, a, MomentForm -> "Right"]
Assuming[0 < a && p >= 1, gtest // Activate // FullSimplify]

edist = ExponentialDistribution[1]
etest = TruncatedExpMoment[edist, a] == TruncatedExpMoment[edist, a, MomentForm -> "Left"] == TruncatedExpMoment[edist, a, MomentForm -> "Right"]
Assuming[0 < a, etest // Activate // FullSimplify]

zeno's People

Contributors

newptcai avatar

Stargazers

 avatar

Watchers

 avatar

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.