From keith at sloan-home.co.uk Sat Jul 3 13:17:31 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Sat, 3 Jul 2021 18:17:31 +0100 Subject: [SciPy-User] Trying to understand Distributions Message-ID: I have a histogram that I would like to fit a gamma and rayleigh curve ideally with a measure of fit. I am struggling to have the histogram and distribution with the same scales. I tried to followhttps://stackoverflow.com/questions/40979643/python-how-to-fit-a-gamma-distribution-from-data and don't really know what I am doing I would like to plot the histogram and distribution in one figure i.e. one for gamma + histogram and another for rayleigh + histogram and as I said some quantitative measure of the fit. Thanks 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) 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') param = stats.rayleigh.fit(counts) # distribution fitting # fitted distribution xx = np.linspace(0,45,1000) pdf_fitted = stats.rayleigh.pdf(xx,loc=param[0],scale=param[1]) pdf = stats.rayleigh.pdf(xx,loc=0,scale=8.5) ax3 = fig.add_subplot(3, 1, 3) plot(xx,pdf,'r-', lw=5, alpha=0.6, label='rayleigh pdf') plot(xx,pdf,'k-', label='Data') plt.bar(x[1:], counts) plt.show() [ 55 77 61 80 94 87 102 115 133 133 123 121 133 122 118 152 142 140 120 96 84 71 39 26 19 9 8 3 0 4] 216.37114598925467 -636.6370861665209 3.3226700375837455 --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /var/folders/cj/z259fmwd41dgzl8mq8nppwd40000gn/T/ipykernel_8820/1690958570.py in 44 plot(xx,pdf,'r-', lw=5, alpha=0.6, label='rayleigh pdf') 45 plot(xx,pdf,'k-', label='Data') ---> 46plt.bar(x[1:], counts) 47 plt.show() 48 /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/pyplot.py inbar(x, height, width, bottom, align, data, **kwargs) 2649 x, height, width=0.8, bottom=None, *, align='center', 2650 data=None, **kwargs): -> 2651return gca().bar( 2652 x, height, width=width, bottom=bottom, align=align, 2653 **({"data": data} if data is not None else {}), **kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/__init__.py ininner(ax, data, *args, **kwargs) 1359 def inner(ax, *args, data=None, **kwargs): 1360 if datais None: -> 1361return func(ax, *map(sanitize_sequence, args), **kwargs) 1362 1363 bound= new_sig.bind(ax, *args, **kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/axes/_axes.py inbar(self, x, height, width, bottom, align, **kwargs) 2302 yerr= self._convert_dx(yerr, y0, y, self.convert_yunits) 2303 -> 2304x, height, width, y, linewidth, hatch = np.broadcast_arrays( 2305 # Make args iterable too. 2306 np.atleast_1d(x), height, width, y, linewidth, hatch) <__array_function__ internals> inbroadcast_arrays(*args, **kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/lib/stride_tricks.py inbroadcast_arrays(subok, *args) 536 args= [np.array(_m, copy=False, subok=subok) for _min args] 537 --> 538shape= _broadcast_shape(*args) 539 540 if all(array.shape== shapefor arrayin args): /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/lib/stride_tricks.py in_broadcast_shape(*args) 418 # use the old-iterator because np.nditer does not handle size 0 arrays 419 # consistently --> 420b= np.broadcast(*args[:32]) 421 # unfortunately, it cannot handle 32 or more arguments directly 422 for posin range(32, len(args), 31): ValueError: shape mismatch: objects cannot be broadcast to a single shape ========== Art & Ceramics =========== https://www.instagram.com/ksloan1952/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pjgfhlnhgohdekdc.png Type: image/png Size: 90988 bytes Desc: not available URL: From robert.kern at gmail.com Sat Jul 3 13:39:04 2021 From: robert.kern at gmail.com (Robert Kern) Date: Sat, 3 Jul 2021 13:39:04 -0400 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: Message-ID: Instead of making your own bar chart from the results of `np.histogram()`, I recommend using `plt.hist(data, bins=binCount, density=True)`. The `density=True` argument is important to make the histogram Y axis commensurable with the PDF Y axis. On Sat, Jul 3, 2021 at 1:19 PM Keith Sloan wrote: > I have a histogram that I would like to fit a gamma and rayleigh curve > ideally with a measure of fit. > I am struggling to have the histogram and distribution with the same > scales. > I tried to follow > https://stackoverflow.com/questions/40979643/python-how-to-fit-a-gamma-distribution-from-data > > and don't really know what I am doing > I would like to plot the histogram and distribution in one figure i.e. one > for gamma + histogram and another for rayleigh + histogram > and as I said some quantitative measure of the fit. > > Thanks > > > from astropy.table import Table, joinimport numpy as npimport matplotlib.pyplot as pltfrom 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 = 30alphaVal = .3 > ##### uminusrfig = 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 statsfrom scipy import statsxfield = '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)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') > param = stats.rayleigh.fit(counts) # distribution fitting# fitted distributionxx = np.linspace(0,45,1000)pdf_fitted = stats.rayleigh.pdf(xx,loc=param[0],scale=param[1])pdf = stats.rayleigh.pdf(xx,loc=0,scale=8.5) > ax3 = fig.add_subplot(3, 1, 3)plot(xx,pdf,'r-', lw=5, alpha=0.6, label='rayleigh pdf')plot(xx,pdf,'k-', label='Data')plt.bar(x[1:], counts)plt.show() > > [ 55 77 61 80 94 87 102 115 133 133 123 121 133 122 118 152 142 140 > 120 96 84 71 39 26 19 9 8 3 0 4] > 216.37114598925467 -636.6370861665209 3.3226700375837455 > > ---------------------------------------------------------------------------ValueError Traceback (most recent call last)/var/folders/cj/z259fmwd41dgzl8mq8nppwd40000gn/T/ipykernel_8820/1690958570.py in 44 plot(xx,pdf,'r-', lw=5, alpha=0.6, label='rayleigh pdf') 45 plot(xx,pdf,'k-', label='Data')---> 46 plt.bar(x[1:], counts) 47 plt.show() 48 > /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/pyplot.py in bar(x, height, width, bottom, align, data, **kwargs) 2649 x, height, width=0.8, bottom=None, *, align='center', 2650 data=None, **kwargs):-> 2651 return gca().bar( 2652 x, height, width=width, bottom=bottom, align=align, 2653 **({"data": data} if data is not None else {}), **kwargs) > /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs) 1359 def inner(ax, *args, data=None, **kwargs): 1360 if data is None:-> 1361 return func(ax, *map(sanitize_sequence, args), **kwargs) 1362 1363 bound = new_sig.bind(ax, *args, **kwargs) > /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/axes/_axes.py in bar(self, x, height, width, bottom, align, **kwargs) 2302 yerr = self._convert_dx(yerr, y0, y, self.convert_yunits) 2303 -> 2304 x, height, width, y, linewidth, hatch = np.broadcast_arrays( 2305 # Make args iterable too. 2306 np.atleast_1d(x), height, width, y, linewidth, hatch) > <__array_function__ internals> in broadcast_arrays(*args, **kwargs) > /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/lib/stride_tricks.py in broadcast_arrays(subok, *args) 536 args = [np.array(_m, copy=False, subok=subok) for _m in args] 537 --> 538 shape = _broadcast_shape(*args) 539 540 if all(array.shape == shape for array in args): > /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/lib/stride_tricks.py in _broadcast_shape(*args) 418 # use the old-iterator because np.nditer does not handle size 0 arrays 419 # consistently--> 420 b = np.broadcast(*args[:32]) 421 # unfortunately, it cannot handle 32 or more arguments directly 422 for pos in range(32, len(args), 31): > ValueError: shape mismatch: objects cannot be broadcast to a single shape > > > > ========== Art & Ceramics ===========https://www.instagram.com/ksloan1952/ > > _______________________________________________ > SciPy-User mailing list > SciPy-User at python.org > https://mail.python.org/mailman/listinfo/scipy-user > -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pjgfhlnhgohdekdc.png Type: image/png Size: 90988 bytes Desc: not available URL: From mikofski at berkeley.edu Mon Jul 5 01:35:37 2021 From: mikofski at berkeley.edu (Dr. Mark Alexander Mikofski PhD) Date: Sun, 4 Jul 2021 22:35:37 -0700 Subject: [SciPy-User] [ANN] Software job opportunity in clean energy Message-ID: Dear Pythonistas, DNV Energy USA is looking for an experienced software engineer to help accelerate the renewable energy transition. Do you know any software engineers interested in clean energy? Would you mind sharing the following link with your network? https://www.linkedin.com/jobs/view/2574048777 Thank you! Mark A. Mikofski -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.schuldei at th-luebeck.de Mon Jul 12 10:03:15 2021 From: andreas.schuldei at th-luebeck.de (Schuldei, Andreas) Date: Mon, 12 Jul 2021 14:03:15 +0000 Subject: [SciPy-User] coordinate and vector transformations between cartesian and cylindrical coordinate system Message-ID: <8248fc6c39e04397877eb3ce0947fafe@th-luebeck.de> Hi, I am looking for ways to do coordinate and vector transformations between cartesian and cylindrical coordinates. Scipy has scipy.spatial.transform, but no ready (easy?) way to do the transformations I look for. Is there a way to use spatial.transform for this that I don't see? Transformations this common surely are done frequently, but I fail to find examples that I can learn from or reuse. Kind regards, Andreas -------------- next part -------------- An HTML attachment was scrubbed... URL: From guillaume at damcb.com Mon Jul 12 10:46:33 2021 From: guillaume at damcb.com (Guillaume Gay) Date: Mon, 12 Jul 2021 16:46:33 +0200 Subject: [SciPy-User] coordinate and vector transformations between cartesian and cylindrical coordinate system In-Reply-To: <8248fc6c39e04397877eb3ce0947fafe@th-luebeck.de> References: <8248fc6c39e04397877eb3ce0947fafe@th-luebeck.de> Message-ID: <43e08f19-5d50-1f1b-87b9-72a621508804@damcb.com> Hi Andreas? What exactly do you have in mind? If your positions are stored as a (n, 3) array of points, Cartesian to cylindrical is (for example): |rho = np.linalg.norm(pos[:, :2], axis=1) theta = np.arctan2(pos[:, 1], pos[:, 0]) z = pos[:, 2] | Conversely if you have three cylindrical coordinates (rho, theta, z), you can get the Cartesian with: |x = pos[:, 0] * np.cos(pos[:, 1]) y = pos[:, 0] * np.sin(pos[:, 1]) z = pos[:, 2] | Hope this helps, Best regards, Guillaume On 12/07/2021 16:03, Schuldei, Andreas wrote: > Hi, > > > I am looking for ways to do coordinate and vector transformations > between cartesian and cylindrical coordinates. Scipy has > scipy.spatial.transform > , > but no ready (easy?) way to do the transformations I look for. Is > there a way to use spatial.transform for this that I don't see? > Transformations this common surely are done frequently, but I fail to > find examples that I can learn from or reuse. > > > Kind regards, > > > Andreas > > > _______________________________________________ > SciPy-User mailing list > SciPy-User at python.org > https://mail.python.org/mailman/listinfo/scipy-user ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.schuldei at th-luebeck.de Mon Jul 12 11:40:16 2021 From: andreas.schuldei at th-luebeck.de (Schuldei, Andreas) Date: Mon, 12 Jul 2021 15:40:16 +0000 Subject: [SciPy-User] coordinate and vector transformations between cartesian and cylindrical coordinate system In-Reply-To: <43e08f19-5d50-1f1b-87b9-72a621508804@damcb.com> References: <8248fc6c39e04397877eb3ce0947fafe@th-luebeck.de>, <43e08f19-5d50-1f1b-87b9-72a621508804@damcb.com> Message-ID: <64dd568c93fb4381b76206833dbad17c@th-luebeck.de> Hi Guillaume, I had come up with this # coordinate transformation from cylindrical to cartesian coordinates def coordinate_transform_cy2ca(r, theta, z): x = np.cos(theta) * r y = np.sin(theta) * r return x, y, z # coordinate transformation back def coordinate_transform_ca2cy(x: np.ndarray, y: np.ndarray, z: np.ndarray): r = np.sqrt(np.square(x) + np.square(y)) theta = np.arctan2(x, y) return r, theta, z # vector transformation from cylindrical to cartesian coordinate system def vector_transform_cy2ca(v_r, v_theta, v_z, R, T, Z): x = v_r * np.cos(T) - R * np.sin(T) * v_theta y = v_r * np.sin(T) + R * np.cos(T) * v_theta return x, y, v_z # vector transformation back def vector_transform_ca2cy(v_x, v_y, v_z, X, Y, Z): sq_devisor = np.square(X) + np.square(Y) devisor = np.sqrt(sq_devisor) r = np.divide((v_x * X + v_y * Y), devisor, out=np.zeros_like(X, dtype=float), where=devisor != 0) theta = np.divide((-Y * v_x + v_y * X), sq_devisor, out=np.zeros_like(Y, dtype=float), where=sq_devisor != 0) return r, theta, v_z # translate (aka move origin) of coordinates (in a meshgrid or otherwise) by vector. # axis orientation and scaling remains the same def coordinate_translate_ca_by_vector(x: np.ndarray, y: np.ndarray, z: np.ndarray, vector: np.ndarray) -> \ Tuple[np.ndarray, np.ndarray, np.ndarray]: x_t: np.ndarray = x - vector[0] y_t: np.ndarray = y - vector[1] z_t: np.ndarray = z - vector[2] return x_t, y_t, z_t based on https://mathepedia.de/Zylinderkoordinaten.html However, as you can guess from my gymnastics with the !=0 in the vector_transform_ca2cy(), there are issues if you need to transform vectors on the z-axis. Incidentally, those are quite important to me and I had hoped that a well-done library would have found a better solution than what I came up with -- which frankly does not work all that well. Furthermore, here http://www.uobabylon.edu.iq/eprints/paper_11_24775_76.pdf (e.g. page 36/37) I find confirmation that vector transformation is not the same as coordinate transformation. However, it disagrees a little with my vector transformation based on https://mathepedia.de/Zylinderkoordinaten.html. So I would have liked a battle-tested lib like scipy that I can rely on. Is anyone familiar with the topic who can share some light on this? Andreas ________________________________ Von: SciPy-User im Auftrag von Guillaume Gay Gesendet: Montag, 12. Juli 2021 16:46:33 An: scipy-user at python.org Betreff: Re: [SciPy-User] coordinate and vector transformations between cartesian and cylindrical coordinate system Hi Andreas? What exactly do you have in mind? If your positions are stored as a (n, 3) array of points, Cartesian to cylindrical is (for example): rho = np.linalg.norm(pos[:, :2], axis=1) theta = np.arctan2(pos[:, 1], pos[:, 0]) z = pos[:, 2] Conversely if you have three cylindrical coordinates (rho, theta, z), you can get the Cartesian with: x = pos[:, 0] * np.cos(pos[:, 1]) y = pos[:, 0] * np.sin(pos[:, 1]) z = pos[:, 2] Hope this helps, Best regards, Guillaume On 12/07/2021 16:03, Schuldei, Andreas wrote: Hi, I am looking for ways to do coordinate and vector transformations between cartesian and cylindrical coordinates. Scipy has scipy.spatial.transform, but no ready (easy?) way to do the transformations I look for. Is there a way to use spatial.transform for this that I don't see? Transformations this common surely are done frequently, but I fail to find examples that I can learn from or reuse. Kind regards, Andreas _______________________________________________ SciPy-User mailing list SciPy-User at python.org https://mail.python.org/mailman/listinfo/scipy-user ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From keith at sloan-home.co.uk Mon Jul 12 16:00:19 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Mon, 12 Jul 2021 21:00:19 +0100 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: Message-ID: <1cec9370-c452-92bd-2cf8-abaae513a309@sloan-home.co.uk> 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/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Mon Jul 12 16:36:09 2021 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 12 Jul 2021 16:36:09 -0400 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: <1cec9370-c452-92bd-2cf8-abaae513a309@sloan-home.co.uk> References: <1cec9370-c452-92bd-2cf8-abaae513a309@sloan-home.co.uk> Message-ID: On Mon, Jul 12, 2021 at 4:06 PM Keith Sloan wrote: > 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) > You don't use fit() on histogram counts. Use it on the data itself. You probably want to fix the `loc` parameter when you do the fitting. It is not typical to allow a zero-shifted gamma distribution (though I am told that astronomy is a place where that does happen). We can use floc=0 to fix that value and we can ignore it when it comes out of the output. gam_shape, _, gam_scale = stats.gamma.fit(RErange1[xfield].data, floc=0.0) Here's a quick demonstration with 100 points that I randomly draw from a gamma distribution: |3> data = stats.gamma.rvs(3, scale=2.0, size=100) |4> data array([ 3.07534256, 4.57813927, 13.8711741 , 6.57534761, 5.28268719, 7.7073074 , 2.95929127, 7.58245554, 6.10107878, 3.52840919, 2.91885749, 4.05885291, 5.03287215, 10.76342819, 8.6441407 , 8.64011327, 5.461707 , 6.15034854, 2.84274024, 8.16282873, 5.111948 , 11.0312346 , 0.50150262, 4.31496838, 5.78209971, 9.0395057 , 3.97753423, 2.81673685, 1.71633995, 9.24401038, 7.50455745, 3.90409068, 4.56853541, 16.55915147, 2.33004283, 2.89232249, 10.0872901 , 3.67701972, 9.15203612, 3.33052913, 5.38745436, 3.95826717, 3.69810183, 5.52858701, 6.04013903, 1.41587988, 4.53861925, 7.65106151, 4.05856947, 6.02678829, 6.08308182, 4.22620438, 9.93515377, 9.45789334, 3.17088024, 10.59471748, 12.19263839, 8.12720946, 8.05421344, 5.31204559, 4.65193752, 6.83243734, 0.85212066, 16.05784841, 1.97212606, 6.28613507, 8.00692823, 4.0366943 , 5.07313536, 9.36507581, 7.28824511, 6.38240736, 3.4051997 , 6.24772202, 3.11340298, 9.00223885, 6.87387583, 4.75206877, 3.68490716, 6.71069272, 2.43124401, 11.01701724, 5.33665806, 4.36158851, 5.89422855, 6.60390376, 8.24682823, 4.60149744, 5.11966798, 1.72012758, 3.85308752, 4.13263933, 6.71598009, 5.47673371, 2.89124835, 4.88451718, 6.69019804, 2.82428072, 6.06868802, 11.30380543]) |5> stats.gamma.fit(data, floc=0) (3.6909888310977736, 0, 1.6193634011500304) 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') > Now be sure to use all of the fitted parameters, not just the shape parameter (we can ignore the loc= parameter since we fixed it to 0). x0, x1 = stats.gamma.ppf([0.1, 0.99], gam_shape, scale=gam_scale) x = np.linspace(x0, x1, 243) # Though this might be better: # x = np.linspace(0, RErange1[xfield].data.max(), 243) ax2.plot(x, stats.gamma.pdf(x, gam_shape, scale=gam_scale), ...) -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: From keith at sloan-home.co.uk Mon Jul 12 23:41:09 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Tue, 13 Jul 2021 04:41:09 +0100 Subject: [SciPy-User] Trying to understand distributions Message-ID: <1be97ef7-475a-0c5d-db27-d7a5c6888a5e@sloan-home.co.uk> 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/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: A890E1FB-72F6-49CD-9C47-C6B7D3B19C61_4_5005_c.jpeg Type: image/jpeg Size: 44729 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 4EBE756D-E28F-4703-BE85-9FC45E560C60_4_5005_c.jpeg Type: image/jpeg Size: 52467 bytes Desc: not available URL: From keith at sloan-home.co.uk Tue Jul 13 00:14:54 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Tue, 13 Jul 2021 05:14:54 +0100 Subject: [SciPy-User] Trying to understand Distributions Message-ID: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> Again another unsuccessful attempt trying to follow Roberts advice Data is astronomic so loc = 0 is not okay ax4 = fig.add_subplot(4, 1, 4) ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) print(ag2, bg2, cg2) x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, scale=cg2) x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) ax4.plot(x, stats.gamma.pdf(x, ag2, scale = cg2),'r-', lw=5, alpha=0.6, label='gamma pdf') plt.show() -- ========== Art & Ceramics =========== https://www.instagram.com/ksloan1952/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Tue Jul 13 00:19:51 2021 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 13 Jul 2021 00:19:51 -0400 Subject: [SciPy-User] Trying to understand distributions In-Reply-To: <1be97ef7-475a-0c5d-db27-d7a5c6888a5e@sloan-home.co.uk> References: <1be97ef7-475a-0c5d-db27-d7a5c6888a5e@sloan-home.co.uk> Message-ID: On Mon, Jul 12, 2021 at 11:42 PM Keith Sloan wrote: > And can get what looks like a gamma fit with > > ax3 = fig.add_subplot(4, 1, 3) > ag1, bg1, cg1 =stats.gamma.fit(counts) > Again, do not pass `counts` to `fit()`. `fit()` works on the raw data. Omit this plot. > 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') > Again, you are omitting bg2 and cg2 from the `ppf()` and `pdf()` calls. You need to pass all of them. -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Tue Jul 13 00:23:17 2021 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 13 Jul 2021 00:23:17 -0400 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> Message-ID: Please try to respond to these messages so that the email thread remains intact. You are making a new thread with each email, which makes the discussion difficult to follow. It would help me refer back to what we've gone over previously. On Tue, Jul 13, 2021 at 12:16 AM Keith Sloan wrote: > Again another unsuccessful attempt trying to follow Roberts advice > > Data is astronomic so loc = 0 is not okay > Okay, then don't omit it. > ax4 = fig.add_subplot(4, 1, 4) > > ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) > print(ag2, bg2, cg2) > x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, scale=cg2) > x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) > ax4.plot(x, stats.gamma.pdf(x, ag2, scale = cg2),'r-', lw=5, alpha=0.6, > label='gamma pdf') > x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc=bg2, scale=cg2) x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) ax4.plot(x, stats.gamma.pdf(x, ag2, loc=bg2, scale = cg2),'r-', lw=5, alpha=0.6, label='gamma pdf') -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: From keith at sloan-home.co.uk Tue Jul 13 00:05:13 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Tue, 13 Jul 2021 05:05:13 +0100 Subject: [SciPy-User] Trying to understand distributions Message-ID: If I try to follow Robert Kern's advice to us use all of the fitted parameters but without success 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, scale = cg1),'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, scale = cg2),'r-', lw=5, alpha=0.6, label='gamma pdf') RK -- ========== Art & Ceramics =========== https://www.instagram.com/ksloan1952/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 68DFC6A0-782C-43FD-BC04-97984A8A50AD_4_5005_c.jpeg Type: image/jpeg Size: 36153 bytes Desc: not available URL: From keith at sloan-home.co.uk Tue Jul 13 00:45:17 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Tue, 13 Jul 2021 05:45:17 +0100 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> Message-ID: Thanks for all your help, but still not getting it right ax4 = fig.add_subplot(4, 1, 4) ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) print(ag2, bg2, cg2) x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc = bg2, scale=cg2) #x = np.linspace(stats.gamma.ppf(x0,x1), int(ag2)) x = np.linspace(stats.gamma.ppf(x0,x1), 100) ax4.plot(x, stats.gamma.pdf(x, ag2, loc= bg2, scale = cg2),'r-', lw=5, alpha=0.6, label='gamma pdf') plt.show() blank On 13/07/2021 05:34, Robert Kern wrote: > Sorry, please reply, but to the mailing list, not just me personally. > The mailing list is set up so that most mail software will default to > replying to the mailing list. > > Don't use `int(ag2)` for the number of steps in the linspace(). It's > probably not a suitable value. Try 100. > > On Tue, Jul 13, 2021 at 12:30 AM Keith Sloan > wrote: > > Still doing something wrong > > ax4 = fig.add_subplot(4, 1, 4) > ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) > print(ag2, bg2, cg2) > x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc = bg2, scale=cg2) > x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) > ax4.plot(x, stats.gamma.pdf(x, ag2, loc= bg2, scale = cg2),'r-', > lw=5, alpha=0.6, label='gamma pdf') > > plt.show() > > blank > On 13/07/2021 05:23, Robert Kern wrote: >> Please try to respond to these messages so that the email thread >> remains intact. You are making a new thread with each email, >> which makes the discussion difficult to follow. It would help me >> refer back to what we've gone over previously. >> >> On Tue, Jul 13, 2021 at 12:16 AM Keith Sloan >> > wrote: >> >> Again another unsuccessful attempt trying to follow Roberts >> advice >> >> Data is astronomic so loc = 0 is not okay >> >> Okay, then don't omit it. >> >> ax4 = fig.add_subplot(4, 1, 4) >> >> ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) >> print(ag2, bg2, cg2) >> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, scale=cg2) >> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) >> ax4.plot(x, stats.gamma.pdf(x, ag2, scale = cg2),'r-', lw=5, >> alpha=0.6, label='gamma pdf') >> >> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc=bg2, scale=cg2) >> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) >> ax4.plot(x, stats.gamma.pdf(x, ag2, loc=bg2, scale = cg2),'r-', >> lw=5, alpha=0.6, label='gamma pdf') >> >> -- >> Robert Kern >> >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at python.org >> https://mail.python.org/mailman/listinfo/scipy-user > > -- > ========== Art & Ceramics =========== > https://www.instagram.com/ksloan1952/ > > > > -- > Robert Kern -- ========== Art & Ceramics =========== https://www.instagram.com/ksloan1952/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: CA809761-78AB-4E2A-9CF5-5BEAE0D7110D_4_5005_c.jpeg Type: image/jpeg Size: 17518 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 1402523F-503F-45CC-AF8D-FBF4B8C9C5BC_4_5005_c.jpeg Type: image/jpeg Size: 18399 bytes Desc: not available URL: From robert.kern at gmail.com Tue Jul 13 00:54:34 2021 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 13 Jul 2021 00:54:34 -0400 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> Message-ID: x = np.linspace(x0, x1, 100) On Tue, Jul 13, 2021 at 12:46 AM Keith Sloan wrote: > Thanks for all your help, but still not getting it right > > ax4 = fig.add_subplot(4, 1, 4) > ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) > print(ag2, bg2, cg2) > x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc = bg2, scale=cg2) > #x = np.linspace(stats.gamma.ppf(x0,x1), int(ag2)) > x = np.linspace(stats.gamma.ppf(x0,x1), 100) > ax4.plot(x, stats.gamma.pdf(x, ag2, loc= bg2, scale = cg2),'r-', lw=5, > alpha=0.6, label='gamma pdf') > > plt.show() > [image: blank] > > > > > On 13/07/2021 05:34, Robert Kern wrote: > > Sorry, please reply, but to the mailing list, not just me personally. The > mailing list is set up so that most mail software will default to replying > to the mailing list. > > Don't use `int(ag2)` for the number of steps in the linspace(). It's > probably not a suitable value. Try 100. > > On Tue, Jul 13, 2021 at 12:30 AM Keith Sloan > wrote: > >> Still doing something wrong >> >> ax4 = fig.add_subplot(4, 1, 4) >> ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) >> print(ag2, bg2, cg2) >> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc = bg2, scale=cg2) >> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) >> ax4.plot(x, stats.gamma.pdf(x, ag2, loc= bg2, scale = cg2),'r-', lw=5, >> alpha=0.6, label='gamma pdf') >> >> plt.show() >> [image: blank] >> On 13/07/2021 05:23, Robert Kern wrote: >> >> Please try to respond to these messages so that the email thread remains >> intact. You are making a new thread with each email, which makes the >> discussion difficult to follow. It would help me refer back to what we've >> gone over previously. >> >> On Tue, Jul 13, 2021 at 12:16 AM Keith Sloan >> wrote: >> >>> Again another unsuccessful attempt trying to follow Roberts advice >>> >>> Data is astronomic so loc = 0 is not okay >>> >> Okay, then don't omit it. >> >>> ax4 = fig.add_subplot(4, 1, 4) >>> >>> ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) >>> print(ag2, bg2, cg2) >>> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, scale=cg2) >>> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) >>> ax4.plot(x, stats.gamma.pdf(x, ag2, scale = cg2),'r-', lw=5, alpha=0.6, >>> label='gamma pdf') >>> >> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc=bg2, scale=cg2) >> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) >> ax4.plot(x, stats.gamma.pdf(x, ag2, loc=bg2, scale = cg2),'r-', lw=5, >> alpha=0.6, label='gamma pdf') >> >> -- >> Robert Kern >> >> _______________________________________________ >> SciPy-User mailing listSciPy-User at python.orghttps://mail.python.org/mailman/listinfo/scipy-user >> >> -- >> ========== Art & Ceramics ===========https://www.instagram.com/ksloan1952/ >> >> > > -- > Robert Kern > > -- > ========== Art & Ceramics ===========https://www.instagram.com/ksloan1952/ > > _______________________________________________ > SciPy-User mailing list > SciPy-User at python.org > https://mail.python.org/mailman/listinfo/scipy-user > -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: CA809761-78AB-4E2A-9CF5-5BEAE0D7110D_4_5005_c.jpeg Type: image/jpeg Size: 17518 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 1402523F-503F-45CC-AF8D-FBF4B8C9C5BC_4_5005_c.jpeg Type: image/jpeg Size: 18399 bytes Desc: not available URL: From pmhobson at gmail.com Tue Jul 13 13:22:53 2021 From: pmhobson at gmail.com (Paul Hobson) Date: Tue, 13 Jul 2021 10:22:53 -0700 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> Message-ID: Keith, Robert's given you great advice. My library (paramnormal) might help you out here if you're still struggling. It's basically a wrapper around select scipy distributions to make the parameterization a little more conventional. http://phobson.github.io/paramnormal/tutorial/fitting.html The gamma distribution is one of the ones whose wrapper has be implemented http://phobson.github.io/paramnormal/api/paramnormal.html#paramnormal.dist.gamma Good luck, -Paul On Mon, Jul 12, 2021 at 9:55 PM Robert Kern wrote: > x = np.linspace(x0, x1, 100) > > On Tue, Jul 13, 2021 at 12:46 AM Keith Sloan > wrote: > >> Thanks for all your help, but still not getting it right >> >> ax4 = fig.add_subplot(4, 1, 4) >> ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) >> print(ag2, bg2, cg2) >> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc = bg2, scale=cg2) >> #x = np.linspace(stats.gamma.ppf(x0,x1), int(ag2)) >> x = np.linspace(stats.gamma.ppf(x0,x1), 100) >> ax4.plot(x, stats.gamma.pdf(x, ag2, loc= bg2, scale = cg2),'r-', lw=5, >> alpha=0.6, label='gamma pdf') >> >> plt.show() >> [image: blank] >> >> >> >> >> On 13/07/2021 05:34, Robert Kern wrote: >> >> Sorry, please reply, but to the mailing list, not just me personally. The >> mailing list is set up so that most mail software will default to replying >> to the mailing list. >> >> Don't use `int(ag2)` for the number of steps in the linspace(). It's >> probably not a suitable value. Try 100. >> >> On Tue, Jul 13, 2021 at 12:30 AM Keith Sloan >> wrote: >> >>> Still doing something wrong >>> >>> ax4 = fig.add_subplot(4, 1, 4) >>> ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) >>> print(ag2, bg2, cg2) >>> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc = bg2, scale=cg2) >>> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) >>> ax4.plot(x, stats.gamma.pdf(x, ag2, loc= bg2, scale = cg2),'r-', lw=5, >>> alpha=0.6, label='gamma pdf') >>> >>> plt.show() >>> [image: blank] >>> On 13/07/2021 05:23, Robert Kern wrote: >>> >>> Please try to respond to these messages so that the email thread remains >>> intact. You are making a new thread with each email, which makes the >>> discussion difficult to follow. It would help me refer back to what we've >>> gone over previously. >>> >>> On Tue, Jul 13, 2021 at 12:16 AM Keith Sloan >>> wrote: >>> >>>> Again another unsuccessful attempt trying to follow Roberts advice >>>> >>>> Data is astronomic so loc = 0 is not okay >>>> >>> Okay, then don't omit it. >>> >>>> ax4 = fig.add_subplot(4, 1, 4) >>>> >>>> ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data) >>>> print(ag2, bg2, cg2) >>>> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, scale=cg2) >>>> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) >>>> ax4.plot(x, stats.gamma.pdf(x, ag2, scale = cg2),'r-', lw=5, alpha=0.6, >>>> label='gamma pdf') >>>> >>> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc=bg2, scale=cg2) >>> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2))) >>> ax4.plot(x, stats.gamma.pdf(x, ag2, loc=bg2, scale = cg2),'r-', lw=5, >>> alpha=0.6, label='gamma pdf') >>> >>> -- >>> Robert Kern >>> >>> _______________________________________________ >>> SciPy-User mailing listSciPy-User at python.orghttps://mail.python.org/mailman/listinfo/scipy-user >>> >>> -- >>> ========== Art & Ceramics ===========https://www.instagram.com/ksloan1952/ >>> >>> >> >> -- >> Robert Kern >> >> -- >> ========== Art & Ceramics ===========https://www.instagram.com/ksloan1952/ >> >> _______________________________________________ >> SciPy-User mailing list >> SciPy-User at python.org >> https://mail.python.org/mailman/listinfo/scipy-user >> > > > -- > Robert Kern > _______________________________________________ > SciPy-User mailing list > SciPy-User at python.org > https://mail.python.org/mailman/listinfo/scipy-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: CA809761-78AB-4E2A-9CF5-5BEAE0D7110D_4_5005_c.jpeg Type: image/jpeg Size: 17518 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 1402523F-503F-45CC-AF8D-FBF4B8C9C5BC_4_5005_c.jpeg Type: image/jpeg Size: 18399 bytes Desc: not available URL: From keith at sloan-home.co.uk Wed Jul 14 10:05:56 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Wed, 14 Jul 2021 15:05:56 +0100 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> Message-ID: <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> Well thanks to advice from Robert I managed to overlay a gamma plot on the histogram, except the gamma looks more like a normal distribution to me. overlay And when I try an add a normal to the mix I have a problem with x axis etc and it looks like a normal distribution w > > _______________________________________________ > SciPy-User mailing list > SciPy-User at python.org > https://mail.python.org/mailman/listinfo/scipy-user -- ========== Art & Ceramics =========== https://www.instagram.com/ksloan1952/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 796DAA21-6CB2-432F-8C95-04BEB2B75750.jpeg Type: image/jpeg Size: 261034 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: AF0ADDD2-E65A-4B46-90EF-06EDA6DE74A6.jpeg Type: image/jpeg Size: 241567 bytes Desc: not available URL: From robert.kern at gmail.com Wed Jul 14 10:31:27 2021 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 14 Jul 2021 10:31:27 -0400 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> Message-ID: On Wed, Jul 14, 2021 at 10:07 AM Keith Sloan wrote: > And when I try an add a normal to the mix I have a problem with x axis etc > and it looks like a normal distribution > [image: w] > > You'll notice that your shape parameter is very high. The Gamma distribution does asymptotically approach the normal distribution as the shape parameter increases. Your shape parameter is very large. One issue is that it looks like your `uminusr` data is truncated ("censored") to omit any values less than 1.8. The fitting procedure in `fit()` assumes that you are giving it uncensored data. That's driving it to make the left tail as low as possible and driving the Gamma to look more normal. -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: AF0ADDD2-E65A-4B46-90EF-06EDA6DE74A6.jpeg Type: image/jpeg Size: 241567 bytes Desc: not available URL: From keith at sloan-home.co.uk Wed Jul 14 10:45:46 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Wed, 14 Jul 2021 15:45:46 +0100 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> Message-ID: Thanks for all the help but still experiencing further problems, maybe it is just me but there seems inconsistencies between distributions and fit, ppt and pdf calls. 1) Trying to fit exponential, fit does not give scale but pdf seems to accept a scale value 2) Also a gamma plot of a second distribution is not showing curve 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 = 100 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(4, 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) ag, bg, cg =stats.gamma.fit(RErange1[xfield].data) print(ag, bg, cg) xg0, xg1 = stats.gamma.ppf([0.01, 0.99], ag, loc = bg, scale=cg) xg = np.linspace(xg0,xg1, int(ag)) an, bn =stats.norm.fit(RErange1[xfield].data) print(an, bn) xn0, xn1 = stats.norm.ppf([0.01, 0.99]) xn = np.linspace(xn0,xn1,100) ax1.plot(xg, stats.gamma.pdf(xg, ag, loc=bg, scale = cg),'r-', lw=2, alpha=0.6, label='gamma pdf') ax1.plot(xn, stats.norm.pdf(xn, an, bn),'y-', lw=2, alpha=0.6, label='normal pdf') ax1.hist(RErange1[xfield].data, bins=binCount, density=True) xfield = 'CountInCyl' #counts, bins = np.histogram(RErange1[xfield].data,bins=binCount) #print(counts) ax2 = fig.add_subplot(4, 1, 2) ax2.set_ylabel('Count In Cyl') ax2.set_xlabel(xfield) #ae, be, ce = stats.expon.fit(RErange1[xfield].data) ae, be = stats.expon.fit(RErange1[xfield].data) xe0, xe1 = stats.expon.ppf([0.01, 0.99]) xe = np.linspace(xe0,xe1,100) #ax2.plot(xg, stats.expon.pdf(xe, ae, loc=be, scale = ce),'r-', lw=2, alpha=0.6, label='gamma pdf') ax2.hist(RErange1[xfield].data, bins=binCount, density=True) xfield = 'DistanceTo5nn' ax3 = fig.add_subplot(4, 1, 3) ax3.set_ylabel('Distance to 5nn') ax3.set_xlabel(xfield) ag, bg, cg =stats.gamma.fit(RErange1[xfield].data) print(ag, bg, cg) xg0, xg1 = stats.gamma.ppf([0.01, 0.99], ag, loc = bg, scale=cg) xg = np.linspace(xg0,xg1, int(ag)) ax3.hist(RErange1[xfield].data, bins=binCount, density=True) ax3.plot(xg, stats.gamma.pdf(xg, ag, loc=bg, scale = cg),'r-', lw=2, alpha=0.6, label='gamma pdf') plt.show() > _______________________________________________ > SciPy-User mailing list > SciPy-User at python.org > https://mail.python.org/mailman/listinfo/scipy-user -- ========== Art & Ceramics =========== https://www.instagram.com/ksloan1952/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 859F0028-B98F-458B-9C44-13FC19362930.jpeg Type: image/jpeg Size: 84006 bytes Desc: not available URL: From robert.kern at gmail.com Wed Jul 14 10:56:25 2021 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 14 Jul 2021 10:56:25 -0400 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> Message-ID: On Wed, Jul 14, 2021 at 10:47 AM Keith Sloan wrote: > Thanks for all the help but still experiencing further problems, maybe it > is just me but there seems inconsistencies between distributions and fit, > ppt and pdf calls. > > 1) Trying to fit exponential, fit does not give scale but pdf seems to > accept a scale value > > ae, be = stats.expon.fit(RErange1[xfield].data) loc=ae, scale=be The last two parameters in the fit() results are always loc and scale. > xe0, xe1 = stats.expon.ppf([0.01, 0.99]) Don't forget to pass in the fitted parameters. 2) Also a gamma plot of a second distribution is not showing curve > Stop using int(ag) for the number of points in the linspace(). It's usually an inappropriate value. In that second case, int(ag)==1. -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: From keith at sloan-home.co.uk Wed Jul 14 13:24:31 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Wed, 14 Jul 2021 18:24:31 +0100 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> Message-ID: <6fdac486-171d-03da-e0f7-150359eeeafe@sloan-home.co.uk> Still confused by expon.fit only returning two ( same for norm) where as gamma returns a value for the shape as well as loc and scale i.e. get error with ax2 = fig.add_subplot(4, 1, 2) ax2.set_ylabel('Count In Cyl') ax2.set_xlabel(xfield) #ae, be, ce = stats.expon.fit(RErange1[xfield].data) ae, be = stats.expon.fit(RErange1[xfield].data) xe0, xe1 = stats.expon.ppf([0.01, 0.99], loc=ae, scale=be) xe = np.linspace(xe0,xe1,100) ax2.plot(xg, stats.expon.pdf(xe, loc=ae, scale=be),'r-', lw=2, alpha=0.6, label='gamma pdf') ax2.hist(RErange1[xfield].data, bins=binCount, density=True) Does not like the ax2.plot On 14/07/2021 15:56, Robert Kern wrote: > On Wed, Jul 14, 2021 at 10:47 AM Keith Sloan > wrote: > > Thanks for all the help but still experiencing further problems, > maybe it is just me but there seems inconsistencies between > distributions and fit, ppt and pdf calls. > > 1) Trying to fit exponential, fit does not give scale but pdf > seems to accept a scale value > > > ae, be = stats.expon.fit(RErange1[xfield].data) > > loc=ae, scale=be > > The last two parameters in the fit() results are always loc and scale. > > > xe0, xe1 = stats.expon.ppf([0.01, 0.99]) > > Don't forget to pass in the fitted parameters. > > 2) Also a gamma plot of a second distribution is not showing curve > > > Stop using int(ag) for the number of points in the linspace(). It's > usually an inappropriate value. In that second case, int(ag)==1. > > -- > Robert Kern > > _______________________________________________ > SciPy-User mailing list > SciPy-User at python.org > https://mail.python.org/mailman/listinfo/scipy-user -- ========== Art & Ceramics =========== https://www.instagram.com/ksloan1952/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Wed Jul 14 13:42:47 2021 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 14 Jul 2021 13:42:47 -0400 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: <6fdac486-171d-03da-e0f7-150359eeeafe@sloan-home.co.uk> References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> <6fdac486-171d-03da-e0f7-150359eeeafe@sloan-home.co.uk> Message-ID: On Wed, Jul 14, 2021 at 1:25 PM Keith Sloan wrote: > Still confused by expon.fit only returning two ( same for norm) where as > gamma returns a value for the shape as well as loc and scale > The exponential and normal distributions just don't have shape parameters. > i.e. get error with > > ax2 = fig.add_subplot(4, 1, 2) > ax2.set_ylabel('Count In Cyl') > ax2.set_xlabel(xfield) > #ae, be, ce = stats.expon.fit(RErange1[xfield].data) > ae, be = stats.expon.fit(RErange1[xfield].data) > > xe0, xe1 = stats.expon.ppf([0.01, 0.99], loc=ae, scale=be) > xe = np.linspace(xe0,xe1,100) > ax2.plot(xg, stats.expon.pdf(xe, loc=ae, scale=be),'r-', lw=2, alpha=0.6, > label='gamma pdf') > ax2.hist(RErange1[xfield].data, bins=binCount, density=True) > > Does not like the ax2.plot > Because you used ax2.plot(xg, ...) instead of ax2.plot(xe, ...)? -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: From keith at sloan-home.co.uk Thu Jul 15 11:05:26 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Thu, 15 Jul 2021 16:05:26 +0100 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> <6fdac486-171d-03da-e0f7-150359eeeafe@sloan-home.co.uk> Message-ID: Okay I now have three fits I got rid of the clipping on Galaxy Count but gamma and norm still look very similar. Is there another distribution like gamma? but instead of being fatter before the peak is fatter after the peak and would be a better match? i.e in the area between 2.3 and 2.4 I know there are similar distributions to expon but nor familiar with them. 'Count In Cyl' are integer counts so bin set accordingly but would prefer a distribution where the red line went through the midpoint of each bar of the histogram Happy with 'Distance to 5nn' and gamma fit. Thanks in anticipation. -- ========== Art & Ceramics =========== https://www.instagram.com/ksloan1952/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: E0251947-5F5C-4320-BF54-DADE584B6C2C_4_5005_c.jpeg Type: image/jpeg Size: 56078 bytes Desc: not available URL: From robert.kern at gmail.com Thu Jul 15 13:08:25 2021 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 15 Jul 2021 13:08:25 -0400 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> <6fdac486-171d-03da-e0f7-150359eeeafe@sloan-home.co.uk> Message-ID: On Thu, Jul 15, 2021 at 11:06 AM Keith Sloan wrote: > Okay I now have three fits > > I got rid of the clipping on Galaxy Count but gamma and norm still look > very similar. Is there another distribution like > gamma but instead of being fatter before the peak is fatter after the > peak and would be a better match? i.e in the area > between 2.3 and 2.4 > Sure, `johnsonsu` will probably fit. Depending on what you actually want to do with the fitted distribution, you might be better served with a nonparametric KDE instead. > I know there are similar distributions to expon but nor familiar with > them. 'Count In Cyl' are integer counts so bin set accordingly > but would prefer a distribution where the red line went through the > midpoint of each bar of the histogram > If the data is discrete, you probably want to fit one of the discrete distributions instead. https://docs.scipy.org/doc/scipy/reference/stats.html#discrete-distributions You can start with `geom`, but that first bin looks pretty tall for that. Maybe `zipf` or `logser` will work. -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: E0251947-5F5C-4320-BF54-DADE584B6C2C_4_5005_c.jpeg Type: image/jpeg Size: 56078 bytes Desc: not available URL: From keith at sloan-home.co.uk Fri Jul 16 10:05:18 2021 From: keith at sloan-home.co.uk (Keith Sloan) Date: Fri, 16 Jul 2021 15:05:18 +0100 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> <6fdac486-171d-03da-e0f7-150359eeeafe@sloan-home.co.uk> Message-ID: <603c4615-14ac-fa24-6d8d-666ac6b79ee5@sloan-home.co.uk> Thanks On 15/07/2021 18:08, Robert Kern wrote: > On Thu, Jul 15, 2021 at 11:06 AM Keith Sloan > wrote: > > Okay I now have three fits > > I got rid of the clipping on Galaxy Count but gamma and norm still > look very similar. Is there another distribution like > gamma? but instead of being fatter before the peak is fatter after > the peak and would be a better match? i.e in the area > between 2.3 and 2.4 > > Sure, `johnsonsu` will probably fit. Depending on what you actually > want to do with the fitted distribution, you might be better served > with a nonparametric KDE instead. johnsonsu seems to work just fine. > I know there are similar distributions to expon but nor familiar > with them. 'Count In Cyl' are integer counts so bin set accordingly > but would prefer a distribution where the red line went through > the midpoint of each bar of the histogram > > If the data is discrete, you probably want to fit one of the discrete > distributions instead. > > https://docs.scipy.org/doc/scipy/reference/stats.html#discrete-distributions > > > You can start with `geom`, but that first bin looks pretty tall for > that. Maybe `zipf` or `logser` will work. Looked at geom and did not see a fit function Not sure I do want a discrete distribution as what I want to subsequently perform is fits for n sets of the three distributions and see if I can find any correlation between the distribution fit parameters. > > -- > Robert Kern > > _______________________________________________ > SciPy-User mailing list > SciPy-User at python.org > https://mail.python.org/mailman/listinfo/scipy-user -- ========== Art & Ceramics =========== https://www.instagram.com/ksloan1952/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: E0251947-5F5C-4320-BF54-DADE584B6C2C_4_5005_c.jpeg Type: image/jpeg Size: 56078 bytes Desc: not available URL: From chris.barker at noaa.gov Fri Jul 16 14:21:16 2021 From: chris.barker at noaa.gov (Chris Barker) Date: Fri, 16 Jul 2021 11:21:16 -0700 Subject: [SciPy-User] Trying to understand Distributions In-Reply-To: <603c4615-14ac-fa24-6d8d-666ac6b79ee5@sloan-home.co.uk> References: <6fcc14c8-d349-5666-11a0-72dc0d645743@sloan-home.co.uk> <9ace18af-37eb-47a2-f459-cf92e5f32c45@sloan-home.co.uk> <6fdac486-171d-03da-e0f7-150359eeeafe@sloan-home.co.uk> <603c4615-14ac-fa24-6d8d-666ac6b79ee5@sloan-home.co.uk> Message-ID: These data are clearly skewed -- one option is to transform the data with a power transformation: log normal is a famous transformation (skewed the other way), but you can use pretty much anything :-) an exponent > 1 would likely match this data well. Here's one random reference I found with a quick Google: http://seismo.berkeley.edu/~kirchner/eps_120/Toolkits/Toolkit_03.pdf Coincidentally enough -- that was one of the first hits on Google -- but I took that class 25 years ago! -CHB On Fri, Jul 16, 2021 at 7:06 AM Keith Sloan wrote: > Thanks > On 15/07/2021 18:08, Robert Kern wrote: > > On Thu, Jul 15, 2021 at 11:06 AM Keith Sloan > wrote: > >> Okay I now have three fits >> >> I got rid of the clipping on Galaxy Count but gamma and norm still look >> very similar. Is there another distribution like >> gamma but instead of being fatter before the peak is fatter after the >> peak and would be a better match? i.e in the area >> between 2.3 and 2.4 >> > Sure, `johnsonsu` will probably fit. Depending on what you actually want > to do with the fitted distribution, you might be better served with a > nonparametric KDE instead. > > > johnsonsu seems to work just fine. > > I know there are similar distributions to expon but nor familiar with >> them. 'Count In Cyl' are integer counts so bin set accordingly >> but would prefer a distribution where the red line went through the >> midpoint of each bar of the histogram >> > If the data is discrete, you probably want to fit one of the discrete > distributions instead. > > > https://docs.scipy.org/doc/scipy/reference/stats.html#discrete-distributions > > You can start with `geom`, but that first bin looks pretty tall for that. > Maybe `zipf` or `logser` will work. > > Looked at geom and did not see a fit function > > Not sure I do want a discrete distribution as what I want to subsequently > perform is fits for n sets of the three distributions > and see if I can find any correlation between the distribution fit > parameters. > > > -- > Robert Kern > > _______________________________________________ > SciPy-User mailing listSciPy-User at python.orghttps://mail.python.org/mailman/listinfo/scipy-user > > -- > ========== Art & Ceramics ===========https://www.instagram.com/ksloan1952/ > > _______________________________________________ > SciPy-User mailing list > SciPy-User at python.org > https://mail.python.org/mailman/listinfo/scipy-user > -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: E0251947-5F5C-4320-BF54-DADE584B6C2C_4_5005_c.jpeg Type: image/jpeg Size: 56078 bytes Desc: not available URL: From charlesr.harris at gmail.com Sun Jul 18 16:13:08 2021 From: charlesr.harris at gmail.com (Charles R Harris) Date: Sun, 18 Jul 2021 14:13:08 -0600 Subject: [SciPy-User] (no subject) Message-ID: Hi All, On behalf of the NumPy team I am pleased to announce the release of NumPy 1.21.1. The NumPy 1.21.1 is a maintenance release that fixes bugs discovered after the 1.21.0 release. OpenBLAS has also been updated to v0.3.17 to deal with arm64 problems. The Python versions supported for this release are 3.7-3.9. The 1.21.x series is compatible with development Python 3.10 and Python 3.10 will be officially supported after it is released. Wheels can be downloaded from PyPI ; source archives, release notes, and wheel hashes are available on Github . Linux users will need pip >= 0.19.3 in order to install manylinux2010 and manylinux2014 wheels. *Contributors* A total of 11 people contributed to this release. People with a \"+\" by their names contributed a patch for the first time. - Bas van Beek - Charles Harris - Ganesh Kathiresan - Gregory R. Lee - Hugo Defois + - Kevin Sheppard - Matti Picus - Ralf Gommers - Sayed Adel - Sebastian Berg - Thomas J. Fan *Pull requests merged* A total of 26 pull requests were merged for this release. - #19311: REV,BUG: Replace `NotImplemented` with `typing.Any` - #19324: MAINT: Fixed the return-dtype of `ndarray.real` and `imag` - #19330: MAINT: Replace `"dtype[Any]"` with `dtype` in the definiton of\... - #19342: DOC: Fix some docstrings that crash pdf generation. - #19343: MAINT: bump scipy-mathjax - #19347: BUG: Fix arr.flat.index for large arrays and big-endian machines - #19348: ENH: add `numpy.f2py.get_include` function - #19349: BUG: Fix reference count leak in ufunc dtype handling - #19350: MAINT: Annotate missing attributes of `np.number` subclasses - #19351: BUG: Fix cast safety and comparisons for zero sized voids - #19352: BUG: Correct Cython declaration in random - #19353: BUG: protect against accessing base attribute of a NULL subarray - #19365: BUG, SIMD: Fix detecting AVX512 features on Darwin - #19366: MAINT: remove `print()`\'s in distutils template handling - #19390: ENH: SIMD architectures to show\_config - #19391: BUG: Do not raise deprecation warning for all nans in unique\... - #19392: BUG: Fix NULL special case in object-to-any cast code - #19430: MAINT: Use arm64-graviton2 for testing on travis - #19495: BUILD: update OpenBLAS to v0.3.17 - #19496: MAINT: Avoid unicode characters in division SIMD code comments - #19499: BUG, SIMD: Fix infinite loop during count non-zero on GCC-11 - #19500: BUG: fix a numpy.npiter leak in npyiter\_multi\_index\_set - #19501: TST: Fix a `GenericAlias` test failure for python 3.9.0 - #19502: MAINT: Start testing with Python 3.10.0b3. - #19503: MAINT: Add missing dtype overloads for object- and ctypes-based\... - #19510: REL: Prepare for NumPy 1.21.1 release. Cheers, Charles Harris -------------- next part -------------- An HTML attachment was scrubbed... URL: