probability-density

Beta Binomial Function in Python

亡梦爱人 提交于 2019-12-01 19:20:27
I would like to calculate the probability given by a binomial distribution for predetermined x(successes), n(trials), and p(probability) - the later of which is given by a probability mass function Beta(a,b). I am aware of scipy.stats.binom.pmf(x,n,p) - but I am unsure how I can replace p with a probability function. I am also wondering whether I could use the loc argument of scipy.stats.binom.pmf to emulate this behaviour. Wiki says that the compound distribution function is given by f(k|n,a,b) = comb(n,k) * B(k+a, n-k+b) / B(a,b) where B is the beta function, a and b are the original Beta

Matlab: generate random numbers from custom made probability density function

孤人 提交于 2019-12-01 13:46:17
I have a dataset with 3-hourly precipitation amounts for the month of January in the period 1977-1983 (see attachment). However, I want to generate precipitation data for the period 1984-1990 based upon these data. Therefore, I was wondering if it would be possible to create a custom made probability density function of the precipitation amounts (1977-1983) and from this, generate random numbers (precipitation data) for the desired period (1984-1990). Is this possible in Matlab and could someone help me by doing so? Thanks in advance! A histogram will give you an estimate of the PDF -- just

multivariate student t-distribution with python

丶灬走出姿态 提交于 2019-11-30 14:15:31
问题 To generate samples with multivariate t-distribution I use this function: def multivariatet(mu,Sigma,N,M): ''' Output: Produce M samples of d-dimensional multivariate t distribution Input: mu = mean (d dimensional numpy array or scalar) Sigma = scale matrix (dxd numpy array) N = degrees of freedom M = # of samples to produce ''' d = len(Sigma) g = np.tile(np.random.gamma(N/2.,2./N,M),(d,1)).T Z = np.random.multivariate_normal(np.zeros(d),Sigma,M) return mu + Z/np.sqrt(g) but what I am looking

multivariate student t-distribution with python

我的梦境 提交于 2019-11-30 10:07:55
To generate samples with multivariate t-distribution I use this function: def multivariatet(mu,Sigma,N,M): ''' Output: Produce M samples of d-dimensional multivariate t distribution Input: mu = mean (d dimensional numpy array or scalar) Sigma = scale matrix (dxd numpy array) N = degrees of freedom M = # of samples to produce ''' d = len(Sigma) g = np.tile(np.random.gamma(N/2.,2./N,M),(d,1)).T Z = np.random.multivariate_normal(np.zeros(d),Sigma,M) return mu + Z/np.sqrt(g) but what I am looking for now is the multivariate student t-distribution it self so I can calculate the density of elements

Tools to use for conditional density estimation in Python [closed]

江枫思渺然 提交于 2019-11-29 13:03:54
I have a large data set that contains 3 attributes per row: A,B,C Column A: can take the values 1, 2, and 0. Column B and C: can take any values. I'd like to perform density estimation using histograms for P(A = 2 | B,C) and plot the results using python. I do not need the code to do it, I can try and figure that on my own. I just need to know the procedures and the tools that should I use? To answer your over-all question, we should go through different steps and answer different questions: How to read csv file (or text data) ? How to filter data ? How to plot data ? At each stage, you need

How to compute the probability of a value given a list of samples from a distribution in Python?

雨燕双飞 提交于 2019-11-28 17:06:45
Not sure if this belongs in statistics, but I am trying to use Python to achieve this. I essentially just have a list of integers: data = [300,244,543,1011,300,125,300 ... ] And I would like to know the probability of a value occurring given this data. I graphed histograms of the data using matplotlib and obtained these: In the first graph, the numbers represent the amount of characters in a sequence. In the second graph, it's a measured amount of time in milliseconds. The minimum is greater than zero, but there isn't necessarily a maximum. The graphs were created using millions of examples,

Integrate 2D kernel density estimate

北慕城南 提交于 2019-11-28 09:29:35
I have a x,y distribution of points for which I obtain the KDE through scipy.stats.gaussian_kde . This is my code and how the output looks (the x,y data can be obtained from here ): import numpy as np from scipy import stats # Obtain data from file. data = np.loadtxt('data.dat', unpack=True) m1, m2 = data[0], data[1] xmin, xmax = min(m1), max(m1) ymin, ymax = min(m2), max(m2) # Perform a kernel density estimate (KDE) on the data x, y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j] positions = np.vstack([x.ravel(), y.ravel()]) values = np.vstack([m1, m2]) kernel = stats.gaussian_kde(values) f = np

Creating a density histogram in ggplot2?

橙三吉。 提交于 2019-11-27 23:02:55
问题 I want to create the next histogram density plot with ggplot2 . In the "normal" way (base packages) is really easy: set.seed(46) vector <- rnorm(500) breaks <- quantile(vector,seq(0,1,by=0.1)) labels = 1:(length(breaks)-1) den = density(vector) hist(df$vector, breaks=breaks, col=rainbow(length(breaks)), probability=TRUE) lines(den) With ggplot I have reached this so far: seg <- cut(vector,breaks, labels=labels, include.lowest = TRUE, right = TRUE) df = data.frame(vector=vector,seg=seg) ggplot

How to compute the probability of a value given a list of samples from a distribution in Python?

本秂侑毒 提交于 2019-11-27 10:11:14
问题 Not sure if this belongs in statistics, but I am trying to use Python to achieve this. I essentially just have a list of integers: data = [300,244,543,1011,300,125,300 ... ] And I would like to know the probability of a value occurring given this data. I graphed histograms of the data using matplotlib and obtained these: In the first graph, the numbers represent the amount of characters in a sequence. In the second graph, it's a measured amount of time in milliseconds. The minimum is greater