How to programatically get parameter names and values in scipy
Is there any way to get the parameters of a distribution? I know almost every distribution has "loc" and "scale" but theres differences between them, for example alpha has "a", beta has "a" ,"b".
What i want to do is programatically print(after fiting a distribution) key value pairs of parameter,value.
But i dont want to write a print routine for every possible distribution.
2 answers

inspect
ing the_pdf
method appears to work:import inspect # keys [p for p in inspect.signature(stats.beta._pdf).parameters if not p=='x'] # ['a', 'b'] # keys and values dist = stats.alpha(a=1) inspect.signature(stats.alpha._pdf).bind('x', *dist.args, **dist.kwds).arguments # OrderedDict([('x', 'x'), ('a', 1)]) # 'x' probably doesn't count as a parameter

In the end what i did was:
parameter_names = [p for p in inspect.signature(distribution._pdf).parameters if not p=='x'] + ["loc","scale"] parameters = distribution.fit(pd_series) distribution_parameters_dictionary =dict(zip(parameter_names,parameters))
Where pd_series is a pandas series of the data being fitted.
See also questions close to this topic

Comparing list values and storing new ones in a separate list
import csv with open("DADSA RESIT CWK JULY 2018.csv", newline='') as f: r = csv.reader(f) database = list(r) del database[0] names = [] names.append([]) def fillnames(d, n): for j in n: for i in d: if d[i][0] == n[j][0] and d[i][1] == n[j][1]: n[i][2] = n[i][2]+1 else: names.append([d[i][0], d[i][1], 0]) fillnames(database, names) for i in names: print(i)
The code I have here is me scanning in a csv file into a list. I then want to count how many entries share the same name, by scanning each new name into a separate list, then incrementing the number found every time I find a new one. Every time I run this code it returns "TypeError: list indices must be integers or slices, not list."

Changing font of a list python
Say I have some code that makes a list into a 4 by 4 1d array:
nlist = [2,2,4,8, 0,0,0,0, 0,0,0,0, 0,0,0,0] def drawBoard(): count = 0 for i in range(16): print(nlist[i], end = ' ') count += 1 if count == 4: print("") count = 0 print("") drawBoard()
How can I change all the fonts in this list into size 26. I tried doing font = 'times 26' but I don't know where to put it or if that command needs tkinter.

Get mouse coordinates without clicking in matplotlib
In a matplotlib plot, how can I continuously read the coordinates of the mouse when it is moved, but without waiting for clicks? This is possible in matlab, and there is a mpld3 plugin to do almost exactly what I want, but I can't see how to actually access the coordinates from it. There is also the package mpldatacursor, but this seems to require clicks. Searching for things like "matplotlib mouse coordinates without clicking" did not yield answers.
Answers using additional packages such as mpld3 are fine, but it seems like a pure matplotlib solution should be possible.

How to extract coordinates of points after a fit?
I am using the following code in order to smooth my data
a = get_data() y, x = a.T t = np.linspace(0, 1, len(x)) t2 = np.linspace(0, 1, len(x)) x2 = np.interp(t2, t, x) y2 = np.interp(t2, t, y) sigma = 50 x3 = gaussian_filter1d(x2, sigma) y3 = gaussian_filter1d(y2, sigma) x4 = np.interp(t, t2, x3) y4 = np.interp(t, t2, y3) plt.plot(x, y, "o", lw=2) plt.plot(x3, y3, "r", lw=2) plt.plot(x4, y4, "o", lw=2) plt.show()
I found this code here:
line smoothing algorithm in python?My problem is that I need to get points from the new fit which are exactly with the same
x
values as my originalx
values (the points that I have smoothed). The fit works well but thex
values of the new points are different. How can I get points from the new fit which has the samex
value but with the new fity
values. Thex
values for the points starts from 0 and the space between each one should be 1800. 
How add edgelines in contourf , for make one 3D mesh
Have some way of plot or make edgelines in one contourf plot?
I've tried plot lines and with zorder make the edgelines, but not works. The plot that I'm working is bellow.
I need the lines over the contourf plan, for make one mesh.
Link of plot
Code:
from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np plt.close('all') fig = plt.figure(num=None, figsize=(10, 8), dpi=80, facecolor='w', edgecolor='k') fig2 = plt.figure(num=None, figsize=(10, 8), dpi=80, facecolor='w', edgecolor='k') ax = fig.gca(projection='3d') ax.set_xlabel('X', fontsize=14, fontweight='bold') ax.set_ylabel('Y', fontsize=14, fontweight='bold') ax.set_zlabel('Z', fontsize=14, fontweight='bold') cset = [[],[],[]] #plot edge lines for zx in range(0,120,20) : ax.plot([0, 1000], [0,0], zs=zx, color='k', zorder=1) ax.plot([1000,1000], [0, 1000], zs=zx, color='k', zorder=1) for xy in range(0,1100,100) : ax.plot([xy,xy], [0,0], zs=[0,100], color='k', zorder=1) ax.plot([1000,1000], [xy,xy], zs=[0,100], color='k', zorder=1) for xy in range(0,1100,100) : ax.plot([0, 1000], [xy,xy], zs=0, color='k', zorder=1) ax.plot([xy,xy], [0, 1000], zs=0, color='k', zorder=1) #plot right plans for ix in range(0,1000,100) : for zx in range(0,100,20) : X = np.linspace(zx, zx+20, 43) Y = np.linspace(ix, ix+100, 28) X, Y = np.meshgrid(X, Y) varone = np.random.rand(75,28,43) * .455865  3 Z = varone[0,:,:] #right cset[1] = ax.contourf(Z, Y, X, zdir='x', offset=1000, levels=np.linspace(np.min(Z),np.max(Z),30),cmap='jet', zorder=2) # setting 3Daxislimits: ax.set_xticks(np.arange(100, 1100, 100)) #[np.arange(100, 1100, 100)] ax.set_yticks(np.arange(100, 1100, 100)) #[np.arange(100, 1100, 100)] ax.set_xlim3d(100,1100) ax.set_ylim3d(100,1100) ax.set_zlim3d(120,20) plt.show()

Incorporation of Runge Kutta using Numpy and Scipy
I'm trying to solve an ode using RungeKutta with a deltat of 0.1. The range of time needs to be as follow: TStart = 0 and TStop = 1000. This is in milliseconds. Here is the ODE I am currently working on:
import matplotlib.pyplot as plt import numpy as np import pandas as pd from scipy.integrate import * # Capacitance (pF) Cs = 20 # Temperature rates Toriginal = 25 Ti = 42 ag = 1.2 atau = 2.0 q10g= ag**((TiToriginal)/10) q10 = atau**((TiToriginal)/10) # Nernst Potentials VK=90 VNa=50 # Max Conductances in nS gNas = 900 gKs = 900 #Timing T = np.linspace(0, 1000, 100000) #Sodium def minfs(Vs): sigmam=5 thetam=35 return 1/(1 + np.exp((Vsthetam)/sigmam)) def alphahs(Vs): return 0.128*np.exp((Vs+50)/18) def betahs(Vs): return 4/(1+np.exp((Vs+27)/5)) def hinfs(Vs): return alphahs(Vs)/(alphahs(Vs) + betahs(Vs)) def tauh(Vs): return (1/q10)*(1/(alphahs(Vs) +betahs(Vs))) # Delayed Rectifier def ninfs(Vs): sigman=5 thetan=30 return 1/(1+ np.exp((Vsthetan)/sigman)) def tauns(Vs): sigman=5 thetan=30 taunbar=10 return (1/q10)*(taunbar/np.cosh((Vsthetan)/(2*sigman))) #Compute derivatives def compute_derivatives(y, t0): dy = np.zeros((3,)) Vs = y[0] hs = y[1] ns = y[2] iNas = q10g*gNas*(minfs(Vs)**3)*hs*(VsVNa) iKs = q10g*gKs*(ns**4)*(VsVK) dy[0] = (10iKsiNas)/Cs # dn/dt dy[1] = q10*(alphahs(Vs)*(1hs)betahs(Vs)*hs) dy[2] = (ninfs(Vs)ns)/tauns(Vs) return dy # State (Vs, hs, ns) Y = np.array([63,1,0]) Vy = odeint(compute_derivatives, Y, T) fig, ax = plt.subplots(figsize=(12, 7)) ax.plot(T, Vy[:, 0]) ax.set_xlabel('Time (ms)') ax.set_ylabel('Vm (mV)') ax.set_title('HVCRA') plt.grid()

How to estimate gaussian distribution parameters using MLE in Python
I've got a set of data with Gaussian distribution, here is a histogram that shows how they actually look like:
I have to classify these data into two class using bayesian classifier, which I'm doing that using
sklearn
and it's working fine. However as a part of job I have to estimate the distribution parameters of data (σ, μ) using MLE and use them in my classifier.So is there any python library or pseudo code that can estimate the gaussian distribution parameters using maximum likelihood method so I can use the estimated values in my classifier?
I'm looking for something like
mle(data,'distribution',dist)
from Matlab.phat = mle(MPG,'distribution','burr') phat = 34.6447 3.7898 3.5722

Stats Pecl package PhpStorm not found via code completion
I have seen this question and added the package via composer, but to no avail:
PhpStorm: How to add method stubs from a PECL library that PhpStorm doesn't currently support?
(It does appear in the include entry in the settings).
The stats package is also not listed on the main display of the GitHub entry.
The package had been installed via pecl and is up and running and also works; it is already included in my code. It is only the IDE that begs to differ.
How do I include this library in such a way as to have full code coverage in PhpStorm.
Edit: I am currently using this function:
stats_standard_deviation
. It works, but PhpStorm lists it as 'cannot find it'. 
pkstwo error in R
I am running the following code in R:
pkstwo < function(x, tol = 1e06) { if (is.numeric(x)) x < as.double(x) else stop("argument 'x' must be numeric") p < rep(0, length(x)) p[is.na(x)] < NA IND < which(!is.na(x) & (x > 0)) if (length(IND)) p[IND] < .C(stats:::C_pkstwo, length(x[IND]), p = x[IND], as.double(tol), PACKAGE = "stats")$p p }
But when I call
pkstwo(0.1)
I get the following error:Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : object 'C_pkstwo' not found
Could anyone please help me fix this?

How to print all possible combinations of cards?
From a standard 52 cards deck, given 13 random cards, I'm trying to find the possible combinations to be put in 3 slots and print them.
First slot is 5 cards
Second slot is 5 cards
Third slot is 3 cards
No ordering in each slot. (A, B, C, D, E) is the same as (C, D, A, B, E)
The formula is simply 13! / 5!5!3! which is 72,072 possible combinations. (thank you @TiwaAina)
What is the best approach to print out all the possible combinations, and what data structures would I be using to make it most efficient?

Generation of random numbers with differences between consecutive numbers following a distribution
Good afternoon, I'm finding myself in the need to generate a column of 8760 numbers following a Weibull probability density distribution with specific parametres, which has been an easy task so far. Nevertheless, I also need another property to be respected: the differences between any number and the previous one in the column must also follow a probability density distribution, which I haven't chosen yet, amongst gamma, beta or rayleigh. I'm working with Excel and MatLab, and I have no idea how to achieve that, especially considering that I couldn't find any case like this on the internet.
How can I solve this problem?
Thanks

How to select items from a list based on probability
I have lists
a
andb
a = [0.1, 0.3, 0.1, 0.2, 0.1, 0.1, 0.1] b = [apple, gun, pizza, sword, pasta, chicken, elephant]
Now I want to create a new list c of 3 items
the 3 items are chosen form list b based on the probabilities in list a
the items should not repeat in list c
for example output I am looking for
c = [gun,sword,pizza]
or
c = [apple, pizza, pasta]
note (sum of all values of list a is 1,number of items in list a and b is the same, actually i have a thousand items in both list a and b and i want to select hundred items from the list based on probability assigned to them,python3 )
 Visualization of Bivariate Probability Distribution

Discrete distribution not symmetrical
I'm trying to sample a discrete distribution using the
std::discrete_distribution
function. Here is a mwe:// discrete_distribution #include <iostream> #include <random> int main() { const int nrolls = 10000; // number of experiments const int nstars = 100; // maximum number of stars to distribute std::vector<double> weights; weights = {1.28503e22, 1.67881e17, 8.99861e13, 1.70418e08, 9.27031e05, 0.106935, 16.1967, 140.325, 16.1967, 0.106935, 9.27031e05, 1.70418e08, 8.99861e13, 1.67881e17, 1.28503e22}; std::default_random_engine generator; std::discrete_distribution<int> distribution(weights.begin(), weights.end()); for (double x:distribution.probabilities()) std::cout << x << " "; std::cout << std::endl; int p[15]={}; for (int i=0; i<nrolls; ++i) { int number = distribution(generator); ++p[number]; } std::cout << "a discrete_distribution:" << std::endl; for (int i=0; i<15; ++i) std::cout << i << ": " << std::string(p[i]*nstars/nrolls,'*') << std::endl; return 0; }
this gives:
7.43082e25 9.70789e20 5.20354e15 9.8546e11 5.36065e07 0.000618363 0.0936591 0.811444 0.0936591 0.000618363 5.36065e07 9.85459e11 5.10703e15 0 0 a discrete_distribution: 0: 1: 2: 3: 4: 5: 6: ********* 7: ******************************************************************************** 8: ********* 9: 10: 11: 12: 13: 14:
Note the asymmetry, especially the zeros at the end. I can't see what I've done wrong. Is there something wrong with the code, or is some rounding taking place that I can't see. Thanks.

generate set of random probability numbers with a prespecified average
I want to generate a 1000 random probabilities, and I want their average to be 0.642 (after generating them). Update: They should be completely random between 0.0 and 1 (not normally distributed.)
Any way to do this in Excel?
(Just for background: I'm trying to do the first problem on this page using Excel instead of whatever software the author is using.)