All Questions
Tagged with probability probability-density
103
questions
21
votes
3
answers
30k
views
How to compute the probability of a value given a list of samples from a distribution in Python?
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 ...
14
votes
3
answers
15k
views
How to generate random numbers with predefined probability distribution?
I would like to implement a function in python (using numpy) that takes a mathematical function (for ex. p(x) = e^(-x) like below) as input and generates random numbers, that are distributed according ...
11
votes
2
answers
12k
views
Compute area under density estimation curve, i.e., probability
I have a density estimate (using density function) for my data learningTime (see figure below), and I need to find probability Pr(learningTime > c), i.e., the the area under density curve from a ...
5
votes
1
answer
90
views
How to generate random integer that are random "enough"?
I'm trying to solve the 280th problem in Project Euler, and for this I have written the following simulation;
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <...
4
votes
2
answers
6k
views
How to find the probability from a normal probability density function in python?
Basically, I have plotted a normal curve by using the values of mean and standard deviation. The y-axis gives the probability density.
How do I find the probability at a certain value "x" on the x-...
4
votes
2
answers
116
views
JS inverting probabilities
I'm generating a grid of objects, each of which has one of 3 colors. Assume I'm filling a particular grid cell. I know that around this cell there are, for example, 1 object of color 0, 1 of color 1 ...
4
votes
1
answer
859
views
Estimate pdf of a vector using Gaussian Kernel
I am using Gaussian kernel to estimate a pdf of a data based on the equation
where K(.) is Gaussian kernel, data is a given vector. z is bin from 1 to 256. size of bin is 1.
I implemented by matlab ...
4
votes
0
answers
184
views
Get representative values from 2d density
How do you get N pairs of values, which represent a joint probability (2d density) of a much larger pairs of values?
I do MCMC sampling on parameters of a function, and I want to visualize the ...
3
votes
2
answers
7k
views
Generate random samples from arbitrary discrete probability density function in Matlab
I've got an arbitrary probability density function discretized as a matrix in Matlab, that means that for every pair x,y the probability is stored in the matrix:
A(x,y) = probability
This is a ...
3
votes
1
answer
1k
views
Can continuous random variables be converted into discrete using scipy?
If I initialize a subclass of scipy.stats.rv_continuous , for example scipy.stats.norm
>>> from scipy.stats import norm
>>> rv = norm()
Can I convert it into a list of ...
3
votes
1
answer
526
views
Loading additional parameters to scipy's rv_continuous
I am planning to do some basic algebra on continuous, non-analytical random variabels. I want to define their probability density functions as arrays x and f(x).
Yet, I was surprised to find out that ...
3
votes
1
answer
2k
views
Plot PDF of log-normal distribution
I'm using the randn function to generate a Gaussian random variable x1 with mean 0 and variance 1. After generating x1, I generate another Gaussian random variable x with mean m and variance σ2, that ...
2
votes
2
answers
4k
views
How to calculate probability of a point using a probability distribution object?
I'm building up on my preivous question because there is a further issue.
I have fitted in Matlab a normal distribution to my data vector: PD = fitdist(data,'normal'). Now I have a new data point ...
2
votes
1
answer
2k
views
Create a new probability distribution R
I would like to create a new probability density function in R as follows:
P{X=x} = p
P{X=/=x} follows a Poisson distribution with some parameter lambda but normalized s.t. the sum of all ...
2
votes
2
answers
3k
views
Finding probability of Gaussian random variable with range
I am a beginner in MATLAB trying to use it to help me understand random signals, I was doing some Normal probability density function calculations until i came across this problem :
Write a MATLAB ...
2
votes
3
answers
126
views
PDF for sum of uniform variables in sympy.stats module
The problem statement is the following:
let $X_1$ and $X_2$ be uniformly distributed variables over $(0,1)$ and $(0,2)$, find the pdf representing $Z = X_1 + X_2$. In sympy.stats they only have a ...
2
votes
1
answer
1k
views
Sampling from a multivariate probability density function in python
I have a multivariate probability density function P(x,y,z), and I want to sample from it. Normally, I would use numpy.random.choice() for this sort of task, but this function only works for 1-...
2
votes
2
answers
344
views
Ensure that contents of list sums up to 1 for np.random.choice()
The Context
In Python 3.5, I'm making a function to generate a map with different biomes - a 2-dimensional list with the first layer representing the lines of the Y-axis and the items representing ...
2
votes
1
answer
670
views
Error probability function
I have DNA amplicons with base mismatches which can arise during the PCR amplification process. My interest is, what is the probability that a sequence contains errors, given the error rate per base, ...
2
votes
1
answer
3k
views
memory error by using rbf with scipy
I want to plot some points with the rbf function like here to get the density distribution of the points:
if i run the following code, it works fine:
from scipy.interpolate.rbf import Rbf # radial ...
2
votes
1
answer
1k
views
How to identify the modes in a (multimodal) continuous variable
What is the best method for finding all the modes in a continuous variable? I'm trying to develop a java or python algorithm for doing this.
I was thinking about using kernel density estimation, for ...
2
votes
1
answer
4k
views
How to find intersection of two distribution in Matlab
As the title, I am trying to find the intersection of two probability density function to locate the optimal decision point with minimum decision error.
In my case,
One distribution is Rayleigh ...
2
votes
1
answer
433
views
Clustering unstructured text based on similarity and calculating optimum number of clusters
I am a data mining beginner and am trying to first formulate an approach to a clustering problem I am solving.
Suppose we have x writers, each with a particular style (use of unique words etc.). ...
2
votes
0
answers
92
views
Calculating covariance for continuous distributions in R
I know the covariance for discrete distributions can be calculated using the cov and cov.wt functions in R. For example the covariance for the below distribution can be solved like this,
weight <- ...
2
votes
1
answer
569
views
Matlab: Truncated multivariate normal random sampling?
I am wishing to sample from a truncated multivariate normal distribution directly in Matlab.
I am aware I can simply use mvnrnd and check whether the returned value is within the domain of interest....
2
votes
1
answer
1k
views
Superimpose two plots in MATLAB
I have two RV , one uniform and one Gaussian and I would like to superimpose their PDFs. I am trying the hold on function but it does not work, as it displays only second plot. How do I do this in ...
2
votes
0
answers
131
views
How could I plot best the output of my probability density function in python
I am trying to plot the output of the below function. The function itself calculates the probability density for given paramaters. The plot should be bell shaped like the normal distribution but not ...
2
votes
1
answer
1k
views
boost::math::pdf, how does it compute a probability from a normal distribution with just 1 value?
I am using the boost::math::pdf to calculate a probability from a normal distribution. I give a variable which corresponds to distance to the mean and boost::math::pdf gives me a porbability in return....
1
vote
1
answer
1k
views
PDF and CDF plot for central limit theorem using Matlab
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 ...
1
vote
1
answer
474
views
Draw random numbers from a custom probability density function in Matlab
I want to sample R random numbers from a custom probability density function in Matlab.
This is the expression of the probability density function evaluated at x.
I thought about using ...
1
vote
1
answer
748
views
Estimating parameters of Von Mises Distribution Scipy - Inconsistent Answers
I am computing the parameters of a Von Mises distribution by hand and wanted to compare to the Scipy Von Mises fit function.
I am getting inconsistent results from the fit function.
My two datasets ...
1
vote
1
answer
1k
views
Generate exponential distribution in Python
I'm aware of the random.expovariate function but this is not what I need.
I'd like to generate a stream of length N in which each element i between 1 and M is chosen with probability 1/(2^(i+1))
Thus,...
1
vote
3
answers
7k
views
Matlab Plotting Normal Distribution Probability Density Function
I am new to statistics. I have a discriminant function:
g(x) = ln p(x| w)+ lnP(w)
I know it has a normal distribution. I know mü and sigma variables. How can I plot pdf function of it at Matlab?
...
1
vote
1
answer
271
views
R: Why does the sum of multi-variate normal densities not equal to 1
library(mvtnorm)
sigma <- matrix(c(4,2,2,3), ncol=2)
x <- rmvnorm(n=500, mean=c(1,2), sigma=sigma)
> sum(dmvnorm(x, mean = c(1,2), sigma = sigma))
[1] 14.07509
I'm simulating 500 draws of a ...
1
vote
2
answers
882
views
PMF and CDF from a piecewise function in R
Given
p <- function(x) {
if (x == -4) {
0.1
} else if (x == -1) {
0.2
} else if (x == 1) {
0.6
} else if (x == 2) {
0.1
} else {
0
}
}
How would I plot the PMF and ...
1
vote
2
answers
781
views
If Random variable is a function
The basic definition of random variable is that it is a function based on random experiment.the question is that if it is a function say f then how can it take numerical values..
Suppose if ...
1
vote
1
answer
97
views
Probability for a vector x
In machine learning suppose we have a GDA (Gaussian Discriminant Analysis) model for classification.
If y can take values 0 or 1 and x represents the vector with n features(n x 1 dimensional)
What ...
1
vote
1
answer
61
views
a function display logarithm of a pdf in matlab
I need to calculate the density of 50 in a standard normal distribution, actually, the result will return to 0 by pdf('norm',50,0,1), then I try to display the logarithm of it,it doesn't work with log(...
1
vote
1
answer
152
views
Sympy convolution of uniform probability distributions gets intractable too quickly
I have a several independent uniform probability distributions, each with a different width (i.e. they are Uniform(0,width) where width is different for each of the distribution).
I would like to ...
1
vote
1
answer
691
views
Calculate and plot the theoretical normal distribution N(2, 1) in the interval of [-1, 5]
I've been giving the task to calculate and plot the normal distribution N(2, 1) in the interval of [-1, 5]
Here's what I've tried:
vec = np.random.norm(2, 1, 7);
ND = stats.norm(2, 1).pdf(vec)
x = ...
1
vote
1
answer
3k
views
How to compute the probability given a data set in R?
I have a vector with values which distribution is unknown and i want to create another vector with the probabilities of the values i have.
eg.
I have
v <- c(e1, e2, ... , ei)
and i want to ...
1
vote
1
answer
85
views
Comparison and estimation of new curve data via using reference curve mean and std values?
Here I want to compare the power curve of two different turbine.Let us assume you have two tables tb1 for turbine 1(Have X=speed AND X1=power values) and tb2 for turbine 2(have y=speed and y1=power ...
1
vote
0
answers
48
views
Issue regarding Triangular Distribution Function calculation
The daily demand for gasoline in a metropolitan area is best modeled according to the Triangular distribution between 1.25 million and 2.05 million gallons, and with a peak (mode) of 1.85 million ...
1
vote
1
answer
106
views
KL and JS Divergence analysis of PDFs of numbers
I am playing around with divergence metrics, and I found that if I implement the calculations on my own or rely on the built-in libs, I get two different numbers. Now, I don't know what am (is) I (the ...
1
vote
1
answer
196
views
Visualising a sine random variable in python
Given a probability distribution with probability density f(t) = 0.5sin(t) for t in [0,π], plot a graph of the probability density on the interval [0,π] and in the same figure make a histogram of 10^4 ...
1
vote
0
answers
42
views
Calculating various statistics of a bivariate distribtion (in R)
I have a joint probability table for which I would like to calculate basic statistics, e.g.: E(x), standard deviation, covariance, correllation coefficient, etc.
I'm new to R and I've been able to ...
1
vote
0
answers
326
views
Measuring the overlap between two probability distribution
I have many probability distributions, I need to compute the amount of overlap between two probability distributions. I don't know the type of distribution since it really depends on the data itself.
...
1
vote
0
answers
171
views
Convolution of two mixture of densities in R
I am currently trying to do a convolution between a mixture of two lognormal densisites in R using package "distr". The mixtures are given by:
library(distr)
M1 <- ...
1
vote
1
answer
203
views
How to correctly use tensorflow_probability to sampling from random variables' function?
I`m interested in the features of bijectors in tensorflow_probability, so I tried to sampling from a random variable function which is constructed by tfp.bijectors.
I just provide my test code blow, ...
1
vote
0
answers
34
views
probability density and ML mapping
I am trying to solve the below question. Please help me with this.
A pixel in a particular image has a random brightness, X. The distribution of Xdepends on
whether the pixel belongs to an object (O) ...