[task] plot routine for quantile distance quotients
This commit is contained in:
parent
1ed83d786d
commit
19ced8b8c5
@ -405,25 +405,44 @@ class PDFstatistics(object):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def histplot(self ,array , bins = 100, label=None):
|
def histplot(self, array, label=None):
|
||||||
# baustelle
|
# baustelle
|
||||||
|
binlist = []
|
||||||
|
if array[-1] == '5':
|
||||||
|
bfactor = 0.001
|
||||||
|
badd = 0
|
||||||
|
elif array[-1] == '1':
|
||||||
|
bfactor = 0.003
|
||||||
|
badd = 0
|
||||||
|
else:
|
||||||
|
bfactor = 0.006
|
||||||
|
badd = 0.4
|
||||||
|
|
||||||
|
for i in range(100):
|
||||||
|
binlist.append(badd+bfactor*i)
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
plt.hist(self.axis, self.data())
|
plt.hist(eval('self.'+array),bins = binlist)
|
||||||
plt.xlabel('x')
|
plt.xlabel('Values')
|
||||||
plt.ylabel('f(x)')
|
plt.ylabel('Frequency')
|
||||||
plt.autoscale(axis='x', tight=True)
|
#plt.autoscale(axis='x', tight=True)
|
||||||
if self:
|
title_str = 'Quantile distance quotient distribution'
|
||||||
title_str = 'Probability density function '
|
if label:
|
||||||
if label:
|
title_str += ' (' + label + ')'
|
||||||
title_str += label
|
|
||||||
title_str.strip()
|
|
||||||
else:
|
|
||||||
title_str = 'Function not suitable as probability density function'
|
|
||||||
plt.title(title_str)
|
plt.title(title_str)
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
def getTheta(self,number):
|
||||||
|
if number == 0:
|
||||||
|
return self.theta015
|
||||||
|
elif number == 1:
|
||||||
|
return self.theta1
|
||||||
|
elif number == 2:
|
||||||
|
return self.theta2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getPDFDict(self, month, evt):
|
def getPDFDict(self, month, evt):
|
||||||
self.pdfdict = PDFDictionary.from_quakeml(os.path.join(self.directory,month,evt))
|
self.pdfdict = PDFDictionary.from_quakeml(os.path.join(self.directory,month,evt))
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ class ProbabilityDensityFunction(object):
|
|||||||
raise ValueError('value out of bounds: {0}'.format(value))
|
raise ValueError('value out of bounds: {0}'.format(value))
|
||||||
return self.prob_limits((value, self.axis[-1]))
|
return self.prob_limits((value, self.axis[-1]))
|
||||||
|
|
||||||
def prob_limits(self, limits, oversampling=1.):
|
def prob_limits(self, limits, oversampling=10.):
|
||||||
sampling = self.incr / oversampling
|
sampling = self.incr / oversampling
|
||||||
lim = np.arange(limits[0], limits[1], sampling)
|
lim = np.arange(limits[0], limits[1], sampling)
|
||||||
data = self.data(lim)
|
data = self.data(lim)
|
||||||
@ -353,7 +353,6 @@ class ProbabilityDensityFunction(object):
|
|||||||
r = self.axis[-1]
|
r = self.axis[-1]
|
||||||
m = (r + l) / 2
|
m = (r + l) / 2
|
||||||
diff = prob_value - self.prob_lt_val(m)
|
diff = prob_value - self.prob_lt_val(m)
|
||||||
|
|
||||||
while abs(diff) > eps and ((r - l) > self.incr):
|
while abs(diff) > eps and ((r - l) > self.incr):
|
||||||
if diff > 0:
|
if diff > 0:
|
||||||
l = m
|
l = m
|
||||||
@ -366,12 +365,11 @@ class ProbabilityDensityFunction(object):
|
|||||||
def quantile_distance(self, prob_value):
|
def quantile_distance(self, prob_value):
|
||||||
ql = self.quantile(prob_value)
|
ql = self.quantile(prob_value)
|
||||||
qu = self.quantile(1 - prob_value)
|
qu = self.quantile(1 - prob_value)
|
||||||
|
|
||||||
return qu - ql
|
return qu - ql
|
||||||
|
|
||||||
|
|
||||||
def qtile_dist_quot(self,x):
|
def qtile_dist_quot(self,x):
|
||||||
if x < 0 or x > 0.5:
|
if x <= 0 or x >= 0.5:
|
||||||
raise ValueError('Value out of range.')
|
raise ValueError('Value out of range.')
|
||||||
return self.quantile_distance(0.5-x)/self.quantile_distance(x)
|
return self.quantile_distance(0.5-x)/self.quantile_distance(x)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user