Questions tagged [probability-density]

In probability theory, the density of a random variable is a function that describes the relative likelihood for this random variable to take on a given value. DO NOT CONFUSE THIS TAG WITH 'PDF': Adobe's file format.

Overview

From wiki:

In probability theory, a probability density function (pdf), or density of a continuous random variable, is a function that describes the relative likelihood for this random variable to take on a given value. The probability for the random variable to fall within a particular region is given by the integral of this variable’s density over the region. The probability density function is nonnegative everywhere, and its integral over the entire space is equal to one.

Related tags: , , .

Tag Usage

  • DO NOT CONFUSE THIS TAG WITH : Adobe's file format.

  • Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

614 questions
6
votes
2 answers

Random sampling from a dataset, while preserving original probability distribution

I have a set of >2000 numbers, gathered from measurement. I want to sample from this data set, ~10 times in each test, while preserving probability distribution overall, and in each test (to extent approximately possible). For example, in each test,…
Ho1
  • 1,239
  • 1
  • 11
  • 29
6
votes
3 answers

How can I generate a random sample of bin counts given a sequence of bin probabilities?

I have a integer that needs to be split up in to bins according to a probability distribution. For example, if I had N=100 objects going into [0.02, 0.08, 0.16, 0.29, 0.45] then you might get [1, 10, 20, 25, 44]. import numpy as np # sample…
Matt
  • 135
  • 6
6
votes
3 answers

Probability Density Function using the standard library?

Being able to use the std to generate random numbers of different prob distributions is great... Now, Is there any way to compute the probability of a set of numbers given a distribution and its parameters using the standard library? I am…
dudu
  • 675
  • 6
  • 15
5
votes
3 answers

Kernel Density Estimation using scipy's gaussian_kde and sklearn's KernelDensity leads to different results

I created some data from two superposed normal distributions and then applied sklearn.neighbors.KernelDensity and scipy.stats.gaussian_kde to estimate the density function. However, using the same bandwith (1.0) and the same kernel, both methods…
akra1
  • 144
  • 1
  • 1
  • 12
5
votes
2 answers

Plotting probability density function with frequency counts

I want to convert fitted distribution to frequency. import numpy as np import matplotlib.pyplot as plt from scipy import stats %matplotlib notebook # sample data generation np.random.seed(42) data = sorted(stats.lognorm.rvs(s=0.5, loc=1,…
Eric Kim
  • 2,493
  • 6
  • 33
  • 69
5
votes
1 answer

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 #include #include #include /* Directions 1 2 3 4 */ int grid[5][5] =…
5
votes
1 answer

Why does this Kernel Density Estimation have values over 1.0?

I'm trying to analyse the features of the Pima Indians Diabetes Data Set (follow the link to get the dataset) by plotting their probability density distributions. I haven't yet removed invalid 0 data, so the plots sometimes show a bias at the very…
maccaroo
  • 819
  • 2
  • 12
  • 22
5
votes
3 answers

Random number with given PDF in Python

I want to generate an integer random number with a probability distribution function given as a list. For example if pdf=[3,2,1] then I like rndWDist(pdf) to return 0,1, and 2, with probabilities of 3/6, 2/6, and 1/6. I wrote my own…
Hooman
  • 147
  • 1
  • 2
  • 8
5
votes
3 answers

Interpolating Function as PDF in Mathematica

I want to use interpolation of a function as a PDF and be able to use tools like Mean, Probability, CDF and so on. I did the following: f = Interpolation[data]; dist = ProbabilityDistribution[f[x], {x,0,1000}]; And for example when I…
4
votes
1 answer

Normalise bivariate probability density function - python

I'm aiming to normalise a probability density function represented below Norm1. It works when I import the equation straight into ax.contour but not when calling the equation outside. When trying to pass Norm1 into the ax.contour, I'm getting the…
Chopin
  • 96
  • 1
  • 10
  • 35
4
votes
2 answers

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-axis? Is there any Python function for it or how do…
4
votes
2 answers

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 and 2 of color 2, so: const surroundings = { 0: 1,…
4
votes
1 answer

Plot normalized uniform mixture

I need to reproduce the normalized density p(x) below, but the code given does not generate a normalized PDF. clc, clear % Create three distribution objects with different parameters pd1 = makedist('Uniform','lower',2,'upper',6); pd2 =…
4
votes
4 answers

Calculate the values of a probability density function for multiple columns of means and a single column of sigma

Given the sample data sampleDT below, which contains means mean1 to mean10 and the standard deviation sd2, I would appreciate any help to create a function that: for each column of means mean1 to mean10estimate, extract and add to the data frame…
Krantz
  • 1,424
  • 1
  • 12
  • 31
4
votes
2 answers

Integral of dnorm(x, mean=200, sd=20) is not 1

I tried to calculate the integral of the density of the normal distribution with expected value 200 and standard deviation 20. From -Inf to Inf this should be 1. I get the following: > integrate(dnorm, mean=200, sd=20,-Inf, Inf)$value [1]…
Juli Schmitt
  • 41
  • 1
  • 2
1 2
3
40 41