probability

Python: Matplotlib - probability plot for several data set

十年热恋 提交于 2019-12-18 12:39:14
问题 I have several data sets (distribution) as follows: set1 = [1,2,3,4,5] set2 = [3,4,5,6,7] set3 = [1,3,4,5,8] How do I plot a scatter plot with the data sets above with the y-axis being the probability (i.e. the percentile of the distribution in set: 0%-100% ) and the x-axis being the data set names? in JMP, it is called 'Quantile Plot'. Something like image attached: Please educate. Thanks. [EDIT] My data is in csv as such: Using JMP analysis tool, I'm able to plot the probability

Picking a random item based on probabilities

Deadly 提交于 2019-12-18 10:39:12
问题 There's a similar question, I know, but it confused me, so I thought it easier to ask in my way. So I have an array of values, positive and negative. The higher they are, the more probability they have of being chosen. I'm having trouble actually figuring out how to assign the probabilities and then randomly choose one. I'm guessing the array will need to be sorted first, but then I'm a bit lost after that. 回答1: "I have various different sizes of cups of coffee. The larger they are, the more

Picking a random item based on probabilities

一曲冷凌霜 提交于 2019-12-18 10:39:11
问题 There's a similar question, I know, but it confused me, so I thought it easier to ask in my way. So I have an array of values, positive and negative. The higher they are, the more probability they have of being chosen. I'm having trouble actually figuring out how to assign the probabilities and then randomly choose one. I'm guessing the array will need to be sorted first, but then I'm a bit lost after that. 回答1: "I have various different sizes of cups of coffee. The larger they are, the more

Determine all combinations of flipping a coin without using “itertools.product”

ぐ巨炮叔叔 提交于 2019-12-18 09:53:46
问题 I went through similar posts on the forum but all of them suggest using itertools.product but I was wondering if it can be solved without using it. I want to print all the combinations of outcomes for N flips of a coin. This can be done if N is known in advance. So the number of nested loops will be just N. But if N has to be determined dynamically ( input() function) then I am stuck in implementing it in code. In plain English it is easy to imagine that the number of for loops is

Generate random numbers with fix probability

假装没事ソ 提交于 2019-12-18 03:43:34
问题 I red a lot in the forum about this, but all answers were so specific to the the asked question. The nearest one I found to my need was:Probability Random Number Generator by Alon Gubkin. The difference is that, Alon ask to give a one face (which is six) extra chance. In my case, I want to divide the chance for the six faces so that they add up to 100%. For example, face 1 has chance of 40%, face 2 has only 10%, face 3 has 25%, ... etc. How can I do that? 回答1: The single probability check

Plot probability heatmap/hexbin with different sized bins

北慕城南 提交于 2019-12-18 03:14:08
问题 This is related to another question: Plot weighted frequency matrix. I have this graphic (produced by the code below in R): #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 <- sample(c(0,1), numbet, prob=c(5/6,1/6), replace = TRUE) xcum[,i] <- cumsum(x)/(1:numbet) } #Plot the trials as transparent lines so

How do I generate points that match a histogram?

纵然是瞬间 提交于 2019-12-17 22:42:59
问题 I am working on a simulation system. I will soon have experimental data (histograms) for the real-world distribution of values for several simulation inputs. When the simulation runs, I would like to be able to produce random values that match the measured distribution. I'd prefer to do this without storing the original histograms. What are some good ways of Mapping a histogram to a set of parameters representing the distribution? Generating values that based on those parameters at runtime?

PDF and CDF plot for central limit theorem using Matlab

寵の児 提交于 2019-12-17 21:22:59
问题 I am struggling to plot the PDF and CDF graphs of where Sn=X1+X2+X3+....+Xn using central limit theorem where n = 1; 2; 3; 4; 5; 10; 20; 40 I am taking Xi to be a uniform continuous random variable for values between (0,3). Here is what i have done so far - close all %different sizes of input X %N=[1 5 10 50]; N = [1 2 3 4 5 10 20 40]; %interval (1,6) for random variables a=0; b=3; %to store sum of differnet sizes of input for i=1:length(N) %generates uniform random numbers in the interval X

Manual simulation of Markov Chain in R

半世苍凉 提交于 2019-12-17 20:32:31
问题 Consider the Markov chain with state space S = {1, 2} , transition matrix and initial distribution α = (1/2, 1/2) . Simulate 5 steps of the Markov chain (that is, simulate X 0 , X 1 , . . . , X 5 ). Repeat the simulation 100 times. Use the results of your simulations to solve the following problems. Estimate P(X 1 = 1|X 0 = 1) . Compare your result with the exact probability. My solution: # returns Xn func2 <- function(alpha1, mat1, n1) { xn <- alpha1 %*% matrixpower(mat1, n1+1) return (xn) }

Find the probability density of a new data point using “density” function in R

 ̄綄美尐妖づ 提交于 2019-12-17 19:22:09
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 4 years ago . I am trying to find the best PDF of a continuous data that has unknown distribution, using the "density" function in R. Now, given a new data point, I want to find the probability density of this data point based on the kernel density estimator that I have from the "density" function result. How can I do that? 回答1: If your new point will be within the range of values produced