I first became a Python Developer
I enrolled college as a physics major
I started college at the age of 17 at Stevens Institute of Technology in Hoboken, NJ. I graduated high school in three years and had not gotten a chance to take Calc 1 or any AP courses. I enrolled as a physics major, hoping to minor in philosophy and ultimately pursue a career in theoretical physics. …
Today I tackled plotting both probability density functions and kernel density estimations in Python.
In order to first understand probability density functions or PDF’s, we need to first look at the docs for scipy.stats.norm.
A normal continuous random variable.
The location (
loc) keyword specifies the mean. The scale (
scale) keyword specifies the standard deviation.
Given a dataframe and a column in that dataframe, we can calculate the probability density function of a variable using the following:
from scipy import statsdata = df['column']
loc = data.mean()
scale = data.std()pdf = stats.norm.pdf(data, loc=loc, scale=scale)
We can also use stats.norm to…