probability

Probability Random Number Generator

Let's say I'm writing a simple luck game - each player presses Enter and the game assign him a random number between 1-6. Just like a cube. At the end of the game, the player with the highest number wins. Now, let's say I'm a cheater. I want to write the game so player #1 (which will be me) has a probability of 90% to get six, and 2% to...

What's the best way to unit test code that generates random output?

Specifically, I've got a method picks n items from a list in such a way that a% of them meet one criterion, and b% meet a second, and so on. A simplified example would be to pick 5 items where 50% have a given property with the value 'true', and 50% 'false'; 50% of the time the method would return 2 true/3 false, and the other 50%, 3 tru...

how to implement non uniform probability distribution?

I am trying to implement non-uniform probability distribution in genetic algorithm. In the implementation of genetic program, I have an experiment which has 3 outcomes, where each outcome has different probabilities. Let say, probablity of one outcome is 0.85, other is 0.01 and last one is 0.14? P.S: i recently came to know that it is...

Generate Random Numbers with Probabilistic Distribution

Ok, so here's my problem. We are looking at purchasing a data set from a company to augment our existing data set. For the purposes of this question, let's say that this data set ranks places with an organic number (meaning that the number assigned to one place has no bearing on the number assigned to another). The technical range is ...

prolog, a conditional like form

Hi, well i'm having a hard time working with prolog (gprolog). My problem is this, I've the next predicate: prob(factA,factB,X,first):- X=<50. prob(factA,factB,X,second):- X>50,X=<80. prob(factA,factB,X,none):- X>80,X=<100. that is factA have 50% of probability of occur, factB a 30%, and lastly 20% of non of the facts occur. Also ...

General math problem - probability

Maybe sounds weird, but this actually applies to programming: Say you have 100 tickets in a raquet and there are 3 which entitles to a prize. If you buy 10, what is the probability that at least one is a winner? ...

Information theory numerical problem, steady state probability

<(if this is not the right place please direct me from where i can get help on this thank you)> calculate the steady state probability of source emitting a "0" from "Applied coding and information theory for engineers" page 70, chapter 2, example 2.4.4 pi0=1/9 pi1=pi2=2/9 pi3=4/9 For Pr(0) how are the values for Pr(0/Sn) found, by my...

How many random strings does this code generate?

I am considering this random string generator in perl: sub generate_random_string { my $length = 12; my @chars = qw/2 3 4 5 6 7 8 9 A B C D E F G H J K M N P Q R S T U V W X Y Z/; my $str = ''; $str .= $chars[int rand @chars] for 1..$length; return $str; } How many unique strings will this generate? If I extend th...

Wanted: Excel sheet for project estimation by betting /team lottery for the release date

Hello, a while ago I read an article on estimating software projects which had an example of a kind of a tongue - in - cheek approach to project estimation. It worked like this: Every team member, no matter how deeply involved in the planning phase could bet on a finishing date. There was an Excel file with a timeline on the top, and ...

How to approach this algorithm question?

A website has a database of n questions. You click a button and are shown one random question per click. The probability of a particular question showing up at the click event is 1/n. On average, how many clicks would be required to see all the questions in the database? What is the approach required for such questions? ...

Probability of finding the median with finite space.

This is a spin off of this StackOverflow question. Assume that you have a fixed number k of storage locations, and space for two counters. You will receive n items in random order (all permutations of the n items are equally likely). After receiving each item you can either store it in one of the k locations (discarding one of the pre...

What exactly happens if you delete an object? (gcc) (When double-delete crashes?)

Please note that I don't want to solve any problem with my question - I was thinking about probabilities of things to happen and thus was wondering about something: What exactly happens if you delete on object and use gcc as compiler? Last week I was investigating a crash, where a race condition lead to an double delete of an object. ...

Select a random row but with odds

I have a dataset of rows each with an 'odds' number between 1 and 100. I am looking to do it in the most efficient way possible. The odds do not necessarily add up to 100. I have had a few ideas. a) select the whole dataset and then add all the odds up and generate a random number between 1 and that number. Then loop through the datase...

Conditional probability in a joint probability distribution

Given this joint probability distribution, I need to figure out P(Cavity | Toothache OR Catch). I know that P(Cavity | Toothache OR Catch) = P(Cavity AND (Toothache OR Catch)) / P(Toothache OR Catch) but I'm not sure how to solve the numerator here. Thanks. ...

How to find a confidence interval for the total number of events

I have a program which records events that occur with some probability p. After I run it I get k events recorded. How can I calculate how many events there were, recorded or not, with some confidence, say 95%? So for example, after getting 13 events recorded I would like to be able to calculate that there were between 13 and 19 events t...

conditional probability

Hi, Could you inform me please, how can I calculate conditioned probability of several events? for example: P (A | B, C, D) - ? I know, that: P (A | B) = P (A intersection B) / P (B) But, unfortunately, I can't find any formula if an event A depends on several variables. Thanks in advance. ...

Probability of Outcomes Algorithm

I have a probability problem, which I need to simulate in a reasonable amount of time. In simplified form, I have 30 unfair coins each with a different known probability. I then want to ask things like "what is the probability that exactly 12 will be heads?", or "what is the probability that AT LEAST 5 will be tails?". I know basic pr...

Maths Probability

What is the probability of getting a 10 or a 11 when a pair of dice are rolled? How to do ...

How to obtain a value based on a certain probability

I have some functions which generate double, float, short, long random values. I have another function to which I pass the datatype and which should return a random value. Now I need to choose in that function the return value based on the passed datatype. For example, if I pass float, I need: the probability that the return is a float ...

Algorithm for two-dimensional rebinning

I have a 12-by-50 array that needs rebinning. The array represents a bivariate probability distribution, p(a,b), where a and b are non-Cartesian coordinates. However, I want to rebin it so that I have a distribution in Cartesian coordinates, p(x,y). a and b are (mildly) nonlinearly related to x and y, however I make the simplifying ass...