Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

cdf empírica python

# fit an empirical cdf to a bimodal dataset
from matplotlib import pyplot
from numpy.random import normal
from numpy import hstack
from statsmodels.distributions.empirical_distribution import ECDF
# generate a sample
sample1 = normal(loc=20, scale=5, size=300)
sample2 = normal(loc=40, scale=5, size=700)
sample = hstack((sample1, sample2))
# fit a cdf
ecdf = ECDF(sample)
# get cumulative probability for values
print('P(x<20): %.3f' % ecdf(20))
print('P(x<40): %.3f' % ecdf(40))
print('P(x<60): %.3f' % ecdf(60))
# plot the cdf
pyplot.plot(ecdf.x, ecdf.y)
pyplot.show()
Comment

cdf empírica python

# example of a bimodal data sample
from matplotlib import pyplot
from numpy.random import normal
from numpy import hstack
# generate a sample
sample1 = normal(loc=20, scale=5, size=300)
sample2 = normal(loc=40, scale=5, size=700)
sample = hstack((sample1, sample2))
# plot the histogram
pyplot.hist(sample, bins=50)
pyplot.show()
Comment

cdf empírica python

...
# fit a cdf
ecdf = ECDF(sample)
Comment

cdf empírica python

...
# get cumulative probability for values
print('P(x<20): %.3f' % ecdf(20))
print('P(x<40): %.3f' % ecdf(40))
print('P(x<60): %.3f' % ecdf(60))
Comment

cdf empírica python

P(x<20): 0.149
P(x<40): 0.654
P(x<60): 1.000
Comment

PREVIOUS NEXT
Code Example
Python :: integer to boolean numpy 
Python :: use reshape in python with zeros 
Python :: data wrangling python 
Python :: randian angle to degrees using numpy 
Python :: see you tomorrow in italian 
Python :: importando todo o pacote em python 
Python :: using list comprehension to filter out age group pandas 
Python :: numpy collapse last dimension 
Python :: tkinter app example code 
Python :: add input to list python 
Python :: set title name in steamlit 0.790 
Python :: how to get cube root python 
Python :: existing session SeleniumLibrary Instance.open_browser 
Python :: cache in django 
Python :: python list of difference beetwen values in list 
Python :: python list comprehension with filter example 2 
Python :: how to get the number in the tenths place of a integer in python 
Python :: 52277-36880 
Python :: recieve output from java python 
Python :: xkcd remove feature matplotlib 
Python :: multipart encoder 
Python :: sublime python build system 
Python :: sum of ele in arr 
Python :: print without parenthesis 
Python :: python script copy and paste 
Python :: select numbers from a list with a limit python 
Python :: chrome drivers documentation 
Python :: Tableau prep encoding to a set of fields in a flow 
Python :: subplots whitespace 
Python :: select series of columns 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =