probability

Generate Random Numbers with Probabilistic Distribution

≯℡__Kan透↙ 提交于 2019-11-28 05:34:43
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 0 to infinity, but from sample sets that I've seen, it's 0 to 70. Based on the sample, it's most definitely not a uniform distribution (out of 10,000 there are maybe 5 places with a score over 40, 50 with a score over 10, and 1000 with a score over 1). Before we

Weighted random selection using Walker's Alias Method

徘徊边缘 提交于 2019-11-28 05:33:10
问题 I was looking for this algorithm (algorithm which will randomly select from a list of elements where each element has different probability of being picked (weight) ) and found only python and c implementations, after I did a C# one, a bit different (but I think simpler) I thought I should share it, also I need an F# imlementation , if anyone can make it please post an answer using System; using System.Collections.Generic; using System.Linq; namespace ChuckNorris { class Program { static void

How to select a value from a list with non-uniform probabilities?

拜拜、爱过 提交于 2019-11-28 05:21:41
问题 I am looking at the k-means++ initialization algorithm. The following two steps of the algorithm give rise to non-uniform probabilities: For each data point x, compute D(x), the distance between x and the nearest center that has already been chosen. Choose one new data point at random as a new center, using a weighted probability distribution where a point x is chosen with probability proportional to D(x)^2. How can I select with this stated weighted probability distribution in C++? 回答1: With

How can I efficiently calculate the binomial cumulative distribution function?

旧城冷巷雨未停 提交于 2019-11-28 04:45:32
Let's say that I know the probability of a "success" is P. I run the test N times, and I see S successes. The test is akin to tossing an unevenly weighted coin (perhaps heads is a success, tails is a failure). I want to know the approximate probability of seeing either S successes, or a number of successes less likely than S successes. So for example, if P is 0.3, N is 100, and I get 20 successes, I'm looking for the probability of getting 20 or fewer successes. If, on the other hadn, P is 0.3, N is 100, and I get 40 successes, I'm looking for the probability of getting 40 our more successes.

Fitting distributions, goodness of fit, p-value. Is it possible to do this with Scipy (Python)?

血红的双手。 提交于 2019-11-28 04:45:21
INTRODUCTION: I'm a bioinformatician. In my analysis which I perform on all human genes (about 20 000) I search for a particular short sequence motif to check how many times this motif occurs in each gene. Genes are 'written' in a linear sequence in four letters (A,T,G,C). For example: CGTAGGGGGTTTAC... This is the four-letter alphabet of genetic code which is like the secret language of each cell, it’s how DNA actually stores information. I suspect that frequent repetations of a particular short motif sequence (AGTGGAC) in some genes are crucial in a specific biochemical process in the cell.

Create constrained random numbers?

风流意气都作罢 提交于 2019-11-28 04:24:51
问题 CLEANED UP TEXT: How can I create m=5 random numbers that add upp to, say n=100. But, the first random number is say, 10 < x1 < 30, the second random nr is 5 < x2 < 20, the third random nr is 10 < x3 < 25, etc. So these five random numbers add up to 100. How can I create these constrained five numbers? . [[ Related problem A1): The standard way to create five random numbers that add up to 100, is to sample four numbers between [0,100], and add the boundaries 0 and 100, and then sort these six

How to properly hash the custom struct?

放肆的年华 提交于 2019-11-28 04:03:54
问题 In the C++ language there is the default hash-function template std::hash<T> for the most simple types, like std::string , int , etc. I suppose, that these functions have a good entropy and the corresponding random variable distribution is statistically uniform. If it's not, then let's pretend, that it is. Then, I have a structure: struct CustomType { int field1; short field2; string field3; // ... }; I want to hash it, using separate hashes of some of it's fields, say, std::hash(field1) and

Select x random elements from a weighted list in C# (without replacement)

混江龙づ霸主 提交于 2019-11-28 03:58:50
问题 Update : my problem has been solved, I updated the code source in my question to match with Jason's answer. Note that rikitikitik answer is solving the issue of picking cards from a sample with replacement. I want to select x random elements from a weighted list. The sampling is without replacement. I found this answer: https://stackoverflow.com/a/2149533/57369 with an implementation in Python. I implemented it in C# and tested it. But the results (as described below) were not matching what I

How to calculate mean, median, mode and range from a set of numbers

流过昼夜 提交于 2019-11-28 03:33:25
Are there any functions (as part of a math library) which will calculate mean , median, mode and range from a set of numbers. Nico Huysamen Yes, there does seem to be 3rd libraries (none in Java Math). Two that have come up are: http://opsresearch.com/app/ http://www.iro.umontreal.ca/~simardr/ssj/indexe.html but, it is actually not that difficult to write your own methods to calculate mean, median, mode and range. MEAN public static double mean(double[] m) { double sum = 0; for (int i = 0; i < m.length; i++) { sum += m[i]; } return sum / m.length; } MEDIAN // the array double[] m MUST BE

Plot weighted frequency matrix

三世轮回 提交于 2019-11-28 02:51:45
问题 This question is related to two different questions I have asked previously: 1) Reproduce frequency matrix plot 2) Add 95% confidence limits to cumulative plot I wish to reproduce this plot in R: I have got this far, using the code beneath the graphic: #Set the number of bets and number of trials and % lines numbet <- 36 numtri <- 1000 #Fill a matrix where the rows are the cumulative bets and the columns are the trials xcum <- matrix(NA, nrow=numbet, ncol=numtri) for (i in 1:numtri) { x <-