probability-theory

How to get random number with each number has its own probability [duplicate]

最后都变了- 提交于 2019-12-23 00:25:17
问题 This question already has answers here : how to implement non uniform probability distribution? (3 answers) Closed 6 years ago . For example, I want to get random number from set S = {0, 1, 2, 3}. But instead of each number has same probability to shown (which is 25%), now I have different probability for each number, let say {50%, 30%, 20%, 10%}. How do I code this? In Java or C# (I prefer C#). 回答1: The Alias Method is by far my favorite for doing this. http://code.activestate.com/recipes

What is the significance of the stationary distribution of a markov chain given it's initial state?

て烟熏妆下的殇ゞ 提交于 2019-12-13 07:08:57
问题 Let X_n be a MC, P not regular Say we have a stationary dist (pi_0, ..., pi_n) and P(X_0 = i) = 0.2, does this say anything? To be more clear: I ask because Karlin says when a stationary dist is not a limiting dist, P(X_n = i) is dependent on the initial distribution. What does this exactly mean? 回答1: Your title's question requires a lengthy answer; I'd have to just provide some references for you to read more on Markov chains and ergodic theory. However, your specific question: "...when a

How to obtain a value based on a certain probability

半世苍凉 提交于 2019-12-13 06:45:15
问题 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 is 70%, the probability that the return is a double, short or long is 10% each. I can make calls to the other function for generating the corresponding random

outlier detection based on gaussian mixture model

主宰稳场 提交于 2019-12-11 19:35:24
问题 I have a set of data. I want to build a one class distribution from that data. Based on the learned distribution I want to get a probability value for each of the data instance. Based on this probability values (thresholding) I want to build a classifier to classify a particular data instance is comming from that distribution or not. In this case, lets say I have a data of 50x100000 where 50 is the dimension of each data instance, the number of instances are 100000. I am leaning a Gaussian

How to generate a random number with a specific probability density function?

时光毁灭记忆、已成空白 提交于 2019-12-10 10:02:40
问题 I am trying to model shadowing and fast fading for mobile wireless networks. For fast fading, Rayleigh fading is a reasonable model to use. The envelope of the channel response will be Rayleigh distributed. Calling this random variable R, it will have a probability density function (PDF) of PR(r) = ((2r)/Ω)*exp(-r^2/Ω), r >= 0, Ω = 2σ^2 http://en.wikipedia.org/wiki/Rayleigh_fading to see the equation written nicely. So, I have the PDF, now I am just wondering how to get the random variable

Calculating Probability of a Random Variable in a Distribution in Python

假装没事ソ 提交于 2019-12-09 17:19:19
问题 Given a mean and standard-deviation defining a normal distribution, how would you calculate the following probabilities in pure-Python (i.e. no Numpy/Scipy or other packages not in the standard library)? The probability of a random variable r where r < x or r <= x. The probability of a random variable r where r > x or r >= x. The probability of a random variable r where x > r > y. I've found some libraries, like Pgnumerics, that provide functions for calculating these, but the underlying math

Computationally simple pseudo-Gaussian distribution with varying mean and standard deviation?

做~自己de王妃 提交于 2019-12-08 01:48:39
问题 This picture from Wikipedia has a nice example of the sort of functions I'd ideally like to generate: Right now I'm using the Irwin-Hall Distribution, which is more or less a polynomial approximation of the Gaussian distribution...basically, you use uniform random number generator and iterate it x times, and take the average. The more iterations, the more like a Gaussian Distribution it is. It's pretty nice; however I'd like to be able to have one where I can vary the mean. For example, let's

How to create a probability by a given percentage?

﹥>﹥吖頭↗ 提交于 2019-12-07 03:05:36
问题 I'm trying to create a percentage-based probability for a game. E.g. if an item has a 45% chance of a critical hit, that must mean it is 45 of 100 hits would be critical. First, I tried to use a simple solution: R = new Random(); int C = R.Next(1, 101); if (C <= ProbabilityPercent) DoSomething() But in 100 iterations with a chance of e.g. 48%, it gives 40-52 out of 100. Same goes for 49, 50, 51. So, there is no difference between these "percents". The question is how to set a percentage of e

Computationally simple pseudo-Gaussian distribution with varying mean and standard deviation?

情到浓时终转凉″ 提交于 2019-12-06 05:49:17
This picture from Wikipedia has a nice example of the sort of functions I'd ideally like to generate: Right now I'm using the Irwin-Hall Distribution, which is more or less a polynomial approximation of the Gaussian distribution...basically, you use uniform random number generator and iterate it x times, and take the average. The more iterations, the more like a Gaussian Distribution it is. It's pretty nice; however I'd like to be able to have one where I can vary the mean. For example, let's say I wanted a number between the range 0 and 10, but around 7. Like, the mean (if I repeated this

How to generate a random number with a specific probability density function?

回眸只為那壹抹淺笑 提交于 2019-12-05 18:26:44
I am trying to model shadowing and fast fading for mobile wireless networks. For fast fading, Rayleigh fading is a reasonable model to use. The envelope of the channel response will be Rayleigh distributed. Calling this random variable R, it will have a probability density function (PDF) of PR(r) = ((2r)/Ω)*exp(-r^2/Ω), r >= 0, Ω = 2σ^2 http://en.wikipedia.org/wiki/Rayleigh_fading to see the equation written nicely. So, I have the PDF, now I am just wondering how to get the random variable from it? I have looked at these questions: Generate Array of Numbers that fit to a Probability