Trying to understand distributions
Keith Sloan <[email protected]> Tue, 13 Jul 2021 04:41:09 +0100
| Newsgroups | gmane.comp.python.scientific.user |
|---|---|
| Message-ID | <[email protected]> |
Okay I can produce a histogram of my data with either ax1, ax2
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)
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)
And get
Histograms
And can get what looks like a gamma fit with
ax3 = fig.add_subplot(4, 1, 3)
ag1, bg1, cg1 =stats.gamma.fit(counts)
print(ag1, bg1, cg1)
x = np.linspace(stats.gamma.ppf(0.1, ag1),stats.gamma.ppf(0.99, ag1),
int(ag1))
ax3.plot(x, stats.gamma.pdf(x, ag1),'r-', lw=5, alpha=0.6, label='gamma
pdf')
ax4 = fig.add_subplot(4, 1, 4)
ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data)
print(ag2, bg2, cg2)
x = np.linspace(stats.gamma.ppf(0.1, ag2),stats.gamma.ppf(0.99, ag2),
int(ag2))
ax4.plot(x, stats.gamma.pdf(x, ag2),'r-', lw=5, alpha=0.6, label='gamma
pdf')
plt.show()
gamma
But I have a problem if I try and combine the histogram and gamma plots
as they have different x and y scales, what am I missing?
--
========== Art & Ceramics ===========
https://www.instagram.com/ksloan1952/
_______________________________________________
SciPy-User mailing list
[email protected]
https://mail.python.org/mailman/listinfo/scipy-user