probability

PHP rate to chance for event to happen

泄露秘密 提交于 2019-12-11 11:29:52
问题 What I'm trying to do ( but getting totally confused with ) is to make a code in PHP that executes a code based on a chance that's given in decimal numbers (10 decimals max) where as 1 would be 100% chance for the code to be executed. Here's what I tried but is not working properly: <?php /* Rate to chance. */ //max 10 decimals $rate = '0.010000000000'; //<-- should equal 1% chance $chance = $rate*pow(10,10); $random = mt_rand(0,pow(10,10)); if($random < $chance) { echo "Ok."; //should be

Using fminsearch to perform distribution fitting

送分小仙女□ 提交于 2019-12-11 09:54:03
问题 Suppose I have a set of univariate data held in the array errors . I would like to fit a PDF to my observed data distribution. My PDF is defined in a function poissvmwalkpdf , whose definition line looks like this: function p = poissvmwalkpdf(theta, mu, kappa, xi) Here, theta is the error (the variable for which values in errors are instances), and mu , kappa , and xi are parameters of the PDF for which I want to find the best fit using maximum-likelihood estimation. This function returns the

How to generate a probability distribution on an image

南楼画角 提交于 2019-12-11 07:06:08
问题 I have a question as follows: Suppose I have an image(size=360x640(row by col)), and I have a center coordinate that's say is (20, 100). What I want is to generate a probability distribution that has the highest value in that center (20,100), and lower probability value in the neighbor and much more lower value farer than the center. All I figure out is to put a multivariate gaussian (since the dimension is 2D) and set mean to the center(20,100). But is that correct and how do I design the

Random number with probability

三世轮回 提交于 2019-12-11 06:43:43
问题 I am trying to generate a random number and have a probability of x% to get closer of the max value. Problem is that I have no idea how to do this, unless I make some steps? Let's say I'll generate a random number between 1 and 3000. $number = mt_rand(1, 3000) This will return 2700 for example. I would like it to be closer to 1 than 3000. How should I implement a function that will only have a 10% chance to get near 3000? 回答1: Based on the comments on the question you can use the mt_rand

Constraint Satisfaction with Uncertainty

别等时光非礼了梦想. 提交于 2019-12-11 06:29:24
问题 I'm trying to solve a problem in which the satisfaction of constraints cannot always be verified. I can find lots of papers on flexible constraint satisfaction, but that's not quite what I want. Here's an example: P(Jim likes Cheese) = 0.8 P(Joe likes Cheese) = 0.5 P(Sam likes Cheese) = 0.2 P(Jim and Sam are friends) = 0.9 P(Jim and Joe are friends) = 0.5 P(Joe and Sam are friends) = 0.7 Charlie is talking about two cheese-liking friends. Who is he most likely talking about? I'm currently

Inverse Probability Selection (Inverse Fitness Selection of Evolutionary Algorithms)

為{幸葍}努か 提交于 2019-12-11 06:19:14
问题 I need to probabilistically select a sample from a set of data. Say I had a set of values array[12, 15, 29, 17, 12, 29] . The standard approach would be calculate the total (12 + 15 + 29 + 17 + 12 + 29) and then create a spinner that favors the higher value. Kinda like a pie chart where we select at random from the sample set but favor the Individual with the highest value. An example with the numbers above the chance you will randomly select array[0] is 11% while the chance that array[5] is

Is defining a probability distribution costly?

可紊 提交于 2019-12-11 04:59:01
问题 I'm coding a physics simulation and I'm now feeling the need for optimizing it. I'm thinking about improving one point: one of the methods of one of my class (which I call a billion times in several cases) defines everytime a probability distribution. Here is the code: void myClass::myMethod(){ //called billions of times in several cases uniform_real_distribution<> probd(0,1); uniform_int_distribution<> probh(1,h-2); uniform_int_distribution<> probv(1,v-2); //rest of the code } Could I pass

z-score to probability and vice verse in ruby

泄露秘密 提交于 2019-12-11 04:56:54
问题 How can I convert z-score to probability using ruby? Example: z_score = 0 probability should be 0.5 z_score = 1.76 probability should be 0.039204 回答1: According to this https://stackoverflow.com/a/16197404/1062711 post, here is the function that give you the p proba from the z score def getPercent(z) return 0 if z < -6.5 return 1 if z > 6.5 factk = 1 sum = 0 term = 1 k = 0 loopStop = Math.exp(-23) while term.abs > loopStop do term = 0.3989422804 * ((-1)**k) * (z**k) / (2*k+1) / (2**k) * (z**

Select element from collection with probability proportional to element value

一笑奈何 提交于 2019-12-11 04:17:00
问题 I have a list of vertices, from which I have to pick a random vertex with probability proportional to deg(v), where deg(v) is a vertex degree. The pseudo code for this operation look like that: Select u ∈ L with probability deg(u) / Sigma ∀v∈L deg(v) Where u is the randomly selected vertex, L is the list of vertices and v is a vertex in L. The problem is that I don't understand how to do it. Can someone explain to me, how to get this random vertex. I would greatly appreciate if someone can

Truncated normal with a given mean

吃可爱长大的小学妹 提交于 2019-12-11 04:09:13
问题 Is it possible in python to generate a truncated normal distribution with a given expected value? I know that scipy.stats.truncnorm can give a truncated normal distribution that takes the mean of the original normal distribution as a parameter, but I want to create a truncated normal distribution such that the expected value of the truncated distribution is a particular value. Is this possible? 回答1: You could convert between mu and mean, see https://en.wikipedia.org/wiki/Truncated_normal