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
3
votes
2 answers

Can't calculate np.cov() correctly

This question might be silly, but i couldn't find an explanation to that. I am coding the multivariate probability density function from scratch (for study purposes), and one of the things that i need to compute is the covariance matrix of data. I…
3
votes
1 answer

Using C++ discrete distribution with weights taken from a data structure

I am trying to use discrete distribution (here too. However as you see in the examples you do this by writing: std::discrete_distribution distribution {2,2,1,1,2,2,1,1,2,2}; or std::discrete_distribution<> d({40, 10, 10, 40}); which is fine…
KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
3
votes
1 answer

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 there does not seem to be any package that does…
3
votes
1 answer

Follow up to stat_contour_2d bins - interpretation

This is a direct follow up to How to interpret ggplot2::stat_density2d. bins has been re-added as an argument see this thread and the corresponding github issue, but it remains a mistery to me how to interpret those bins. This answer (answer 1)…
tjebo
  • 21,977
  • 7
  • 58
  • 94
3
votes
1 answer

Extract and add to the data values of the probability density function based on a stan linear model

Given the sample data sampleDT and models lm.fit and brm.fit below, I would like to: estimate, extract and add to the data frame the values of the density function for a conditional normal distribution evaluated at the observed level of the…
Krantz
  • 1,424
  • 1
  • 12
  • 31
3
votes
1 answer

Why doesn't "dnorm" sum up to one as a probability?

This may be some basic/fundamental question on 'dnorm' function in R. Let's say I create some z scores through z transformation and try to get the sum out of 'dnorm'. data=c(232323,4444,22,2220929,22323,13) z=(data-mean(data))/sd(data) …
3
votes
1 answer

4 different Matlab functions to estimate the PDF of data give 4 different results

I might be stuck in some details, but I am stuck in at seemingly operation. I have a set of data gaussian_noise (representing white noise with mean = mu, and std_dev = sigma) and I want to plot the PDF of this data. The values of gaussian_noise are…
DbergOber
  • 33
  • 3
3
votes
1 answer

Understanding dnorm and geom_density

x <- seq(-4, 4, length.out = 100) data.frame(x, f = dnorm(x)) %>% ggplot(aes(x, f)) + geom_line() imho, this should give the exact same plot as this: x <- seq(-4, 4, length.out = 100) data.frame(x, f = dnorm(x)) %>% ggplot() + …
3
votes
1 answer

The dimensions in hist for numpy.histogram with density = True

let's say I have this array A: array([ 0.0019879 , -0.00172861, -0.00527226, 0.00639585, -0.00242005, -0.00717373, 0.00371651, 0.00164218, 0.00034572, -0.00864304, -0.00639585, 0.006828 , 0.00354365, 0.00043215, -0.00440795, …
goingdeep
  • 99
  • 1
  • 9
3
votes
2 answers

Confidence interval in python

Is there a function or a package in python to get the 95% or 99% confidence interval of the distributions present in scipy.stats. If not what is easiest alternative for that Here are the distributions (but my priority is halfgennorm and…
3
votes
2 answers

The proper way to plot PDF of a sample of data

I know this must be pretty basic, but what is the proper, accurate way to plot the PDF of some sample data that you know comes from some pop. distribution, like if you generated it using rnorm() or rexp()? The reason I ask is because I know a lot…
Coolio2654
  • 1,589
  • 3
  • 21
  • 46
3
votes
1 answer

Plot beta distribution in R

Using the dataset Lahman::Batting I've estimated parameters for the beta distribution. Now I want to plot this empirically derived beta distribution onto the histogram that I estimated it from. library(dplyr) library(tidyr) library(Lahman) career…
Rich Pauloo
  • 7,734
  • 4
  • 37
  • 69
3
votes
3 answers

Python - calculating pdf from a numpy array distribution

Given an array of values, I want to be able to fit a density function to it and find the pdf of an arbitrary input value. Is this possible, and how would I go about it? There aren't necessarily assumptions of normality, and I don't need the function…
Brian G
  • 65
  • 1
  • 1
  • 4
3
votes
1 answer

Smooth line on histograms in gnuplot

I want to make a smooth line over histograms. So far I have tried all the smooth functions but I am not able to get the result. For the histograms I am using: plot "file.scatter" u (hist($2,width)):(1.0) smooth freq w boxes notitle and the result…
Harris
  • 117
  • 1
  • 2
  • 8
3
votes
1 answer

Exact kernel density value for any point in R

I was wondering if there is a R base way to obtain the exact kernel density at any point desired? As an example, how can I get the exact kernel density at the 3 following points -2, 0, +2 on X-Axis in a plot like below? set.seed(2937107) plot(…
rnorouzian
  • 7,397
  • 5
  • 27
  • 72