Re: Trying to understand Distributions

Keith Sloan <[email protected]> Mon, 12 Jul 2021 21:00:19 +0100
Newsgroups gmane.comp.python.scientific.user
Message-ID <[email protected]>
Okay I changed the plot histogram as advised by Robert Kern ax2 as 
opposed to ax1

but how do I get the correct gamma plot as I am not understanding 
np.linespace other the first parameter is a minimum and second maximum

from astropy.table import Table, join
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import plot

RawMassEClassEmeasure = 
Table.read('../../GAMA_Data/REMassEClassEmeasure.fits')
#print(RawMassEClassEmeasure.colnames)
# CLEAN DATA
#REMassEClassEmeasure = 
RawMassEClassEmeasure[RawMassEClassEmeasure['CountInCyl']> -500]
RErange = RawMassEClassEmeasure[RawMassEClassEmeasure['CountInCyl']> -500]
RErange1 = RErange[RErange['SurfaceDensity']< 50]

binCount = 30
alphaVal = .3

##### uminusr
fig = plt.figure(figsize=(12, 6), dpi=200)
fig.suptitle('Plot - Histogram Red Galaxies for Elliptical Galaxies')
#fig.legend(loc="upper right")
#import scipy.stats as stats
from scipy import stats
xfield = 'uminusr'
counts, bins = np.histogram(RErange1[xfield].data,bins=binCount)
print(counts)
ag, bg, cg =stats.gamma.fit(counts)
print(ag, bg, cg)

ax1 = fig.add_subplot(3, 1, 1)
ax1.set_ylabel('Galaxy Count')
ax1.set_xlabel(xfield)
counts, bins = np.histogram(RErange1[xfield].data,bins=binCount)
ax1.hist(bins[:-1],bins, weights=counts)

ax2 = fig.add_subplot(3, 1, 2)
ax2.hist(RErange1[xfield].data, bins=binCount, density=True)
x = np.linspace(stats.gamma.ppf(0.1, ag),stats.gamma.ppf(0.99, ag), 243)
#ax2.plot(x, stats.gamma.pdf(x, ag),'r-', lw=5, alpha=0.6, label='gamma 
pdf')

-- 
========== Art & Ceramics ===========
https://www.instagram.com/ksloan1952/

_______________________________________________
SciPy-User mailing list
[email protected]
https://mail.python.org/mailman/listinfo/scipy-user