probability

Algorithm to generate Poisson and binomial random numbers?

i've been looking around, but i'm not sure how to do it. i've found this page which, in the last paragraph, says: A simple generator for random numbers taken from a Poisson distribution is obtained using this simple recipe: if x1, x2, ... is a sequence of random numbers with uniform distribution between zero and one, k is the first int...

Monty Hall Problem

Through trying to explain the Monty Hall problem to a friend during class yesterday, we ended up coding it in Python to prove that if you always swap, you will win 2/3 times. We came up with this: import random as r #iterations = int(raw_input("How many iterations? >> ")) iterations = 100000 doors = ["goat", "goat", "car"] wins = 0.0 ...

Computing the probability for a section of a joint distribution

Considering I have a continuous joint distribution of two independent normal random variables (let's assume the independent vars are on the X and Z axis, and the dependent - the joint probability - is on the Y axis), and I have a line anywhere on the XZ plane, how would I compute the probability of a point falling on one side or the othe...

Using one probability set to generate another

How can I generate a bigger probability set from a smaller probability set? This is from Algorithm Design Manual -Steven Skiena Q: Use a random number generator (rng04) that generates numbers from {0,1,2,3,4} with equal probability to write a random number generator that generates numbers from 0 to 7 (rng07) with equal probability.? I t...

What is O value for naive random selection from finite set?

This question on getting random values from a finite set got me thinking... It's fairly common for people to want to retrieve X unique values from a set of Y values. For example, I may want to deal a hand from a deck of cards. I want 5 cards, and I want them to all be unique. Now, I can do this naively, by picking a random card 5 t...

Generate random numbers distributed by Zipf

The Zipf probability distribution is often used to model file size distribution or item access distributions on items in P2P systems. e.g. "Web Caching and Zip like Distribution Evidence and Implications", but neither Boost or the GSL (Gnu Scientific Library) provide an implementation to generate random numbers using this distribution. I...

Simulating sports matches in online game

Hello! In an online manager game (like Hattrick), I want to simulate matches between two teams. A team consists of 11 players. Every player has a strength value between 1 and 100. I take these strength values of the defensive players for each team and calculate the average. That's the defensive quality of a team. Then I take the streng...

How can I compute the probability at a point given a normal distribution in Perl?

Is there a package in Perl that allows you to compute the height of probability distribution at each given point. For example this can be done in R this way: > dnorm(0, mean=4,sd=10) > 0.03682701 Namely the probability of point x=0 falls into a normal distribution, with mean=4 and sd=10, is 0.0368. I looked at Statistics::Distribution...

Generate stochastic random deviates from a density object with R

I have a density object dd created like this: x1 <- rnorm(1000) x2 <- rnorm(1000, 3, 2) x <- rbind(x1, x2) dd <- density(x) plot(dd) Which produces this very non-Gaussian distribution: I would ultimately like to get random deviates from this distribution similar to how rnorm gets deviates from a normal distribution. The way I ...

Open source statistics library for C# for generating random number of various distributions?

This is for simulation. In particular, I'm trying to generate natural sounding words and names, and the uniform distribution in the Random class provides doesn't cut it. This isn't a dupe question because the similar questions weren't look for C# random number generators. ...

Probabilities & Statistics, learning material

I'm not sure how to post this. So I'm setting the question as CW off the bat. Hope you don't mind. It relates to programming in the sense this is where I will be applying it. But it is not a programming question. I'm in need of learning material (in the shape of books preferably) that can teach me Probability and Statistics from the gro...

Probability exercise returning different result that expected

As an exercise I'm writing a program to calculate the odds of rolling 5 die with the same number. The idea is to get the result via simulation as opposed to simple math though. My program is this: # rollFive.py from random import * def main(): n = input("Please enter the number of sims to run: ") hits = simNRolls(n) hits...

How does this MATLAB code work? (probabilities and random sequences)

I saw this code in a comment for the article "Never-ending Shuffled Sequence". I understand the basic premise, but I don't know how it works. The biggest explanation I need is of the first two lines of the while loop. (Because it is written in MATLAB I can only guess at how this code functions.) probabilities = [1 1 1 1 1 1]; unrandomn...

creating distributions in mathematica

I have a function which I know to be a multivariate distribution in (x,y), and mathematica is having numerical stability issues when I form the marginal distributions. For example, marginalizing along y yields the following: 0.e^(154.88-0.5x^2) Since I know the result must be a distribution, I would like to extract just the e^(-.5x^2) ...

Possible outcome in C#

I have to trace all outcome When tossing four coins at once public void TossCoin() { var coin1 = new string[]{ "Head", "Tail" }; var coin2 =new string[] { "Head", "Tail" }; var coin3 =new string[] { "Head", "Tail" }; var coin4 =new string[] { "Head", "Tail" }; var outcome =from first in coin1 from s...

Adjust items chance to be selected from a list

I have a list of items. When I create the list each item has equal chance to be selected. But as an item is selected its chance goes down while the others chance goes up. If a new item is added during the process, it should have the highest chance to be selected with its chances falling off as it is selected. I am looking for a good ...

How to test the quality of a probabilities estimator?

I created a heuristic (an ANN, but that's not important) to estimate the probabilities of an event (the results of sports games, but that's not important either). Given some inputs, this heuristics tell me what are the probabilities of the event. Something like : Given theses inputs, team B as 65% chances to win. I have a large set of i...

algorithms to evaluate user responses

I'm working on a web application which will be used for classifying photos of automobiles. The users will be presented with photos of various vehicles, and will be asked to answer a series of questions about what they see. The results will be recorded to a database, averaged, and displayed. I'm looking for algorithms to help me identify...

Does an open-source poker-related math library exist?

I would like to develop a poker odds application that can give the probability of various game situations. Since the application will be mostly statistical analysis, I figured I would see if someone else had already written a library that implements the required mathematics. I would prefer cross-platform open-source in C++, but that's n...

How do I efficiently estimate a probability based on a small amount of evidence?

I've been trying to find an answer to this for months (to be used in a machine learning application), it doesn't seem like it should be a terribly hard problem, but I'm a software engineer, and math was never one of my strengths. Here is the scenario: I have a (possibly) unevenly weighted coin and I want to figure out the probability o...