probability

Three type of Balls from Bag

末鹿安然 提交于 2019-12-13 11:07:26
问题 I have a problem which sounds like this: We have a bag with balls in. There are R red balls, B blue balls and G green balls. I need to find the minimum number of extractions from the bag such that i am sure that i will have at least K balls of same colour. Anyone can help with any idea? Or tips, etc? 回答1: If K>max(R,G,B) then the problem has no solution. So let's assume K <= max(R,G,B) . If you don't have any control over which ball gets extracted, you'll need at most (i.e. this is a lower

making non-uniform probability distribution in java

核能气质少年 提交于 2019-12-13 08:59:58
问题 i am having total no of elements(say 500) in a java class, which will generate a population of 3 diff type (type A,Type B and Type C) of objects with a probability of A=0.3,B=0.2,C=0.5. i am not able to find a nice and easy solution ,can any one help me with a sample code or some reference Thanks in advance 回答1: For each element, generate a random int r between 0 and 9. If 0 <= r < 3 then Type A. If 3 <= r < 5 then Type B. If 5 <= r < 10 then Type C. 来源: https://stackoverflow.com/questions

to find count of each line in another file

百般思念 提交于 2019-12-13 08:22:58
问题 How can i get now of times a particular line of one file present in another file I have two files rule.txt and full.txt.I want to check count of each line in rule.txt in full.txt.please help me In file rule.txt contain NP--->N_NNP N_NN_S_NU N_NNP N_NNP N_NN_O_NU VGF--->V_VM_VF The another file full.txt contains 1000 of such type of rules. i want to calculate count of each rule in the rule.txt and I want to get output as line with count.that count is needed for the calculation of probability

Sliding probability scale for randomly picking a number between a range [closed]

江枫思渺然 提交于 2019-12-13 08:18:03
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . Let's say I have lots of cash I want to give out in random increments between $500 and $5,000. I'd like the lower end of the range to be much more probable than the higher range. What's the most efficient algorithm I can write in Ruby to randomly hand out cash in this manner? 回答1: I think the

Outcome of a simulated dice and coin toss in R [closed]

[亡魂溺海] 提交于 2019-12-13 07:50:14
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . The experiment involves rolling a fair die and getting x say, then tossing a fair coin x number of times and recording the number of tails. I need to do

choose k items from a set of x and y to meet certain criteria

坚强是说给别人听的谎言 提交于 2019-12-13 07:17:04
问题 I have given x and y items , I need to choose some x and some y with some constrain say x < 10 and y < 5 and the total number should be p . How to solve such problem. Algorithm/ mathematical technique. 回答1: The trick is we only need to go through one array (e.g. the x_array), and we can work out y using p-x=y. Now we only need to ensure y is in the y_array and we know we have our answer. To ensure y is in the y_array, we make a set or binary search tree for fast look-ups. Here is some python

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 determine probability of 0 to N events occurring given probability of each of those N events?

核能气质少年 提交于 2019-12-13 06:45:45
问题 First time posting here, so if I make a mistake with something let me know and I'd be more than happy to fix it! Given N events, each of which have an individual probability (from 0 to 100%) of occurring, I'd like to determine the probability of 0 to N of those events occurring together. For example, if I have event 1, 2, 3,...,N and 5 (E1, E2, E3...,EN) where the individual probability of a specific event occurring is as follows: E1 = 30% probability of occurring E2 = 40% probability of

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

Hourly prize instant giveaway algorithm

拥有回忆 提交于 2019-12-13 05:22:50
问题 I've been asked to build a prize giveaway web page with the following competition parameters: A user can only enter the competition once per day It's an instant win competition, the user will know if they have won or not when they enter We want to give away on average 1 prize per hour My first thought was at the start of each hour, to select a random second within that hour for the prize to be given away. The first user who enters after that second is the winner. If a hour goes past where no