Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 10 months ago.
Improve this question
My goal is to display a non-decreasing stepwise curve F. For each x-axis point, computing the corresponding F(x) is fairly computational, hence discretizing the x-axis and computing every corresponding F(x) point may take a lot of time.
My idea is to compute the curve by dichotomy.
Starting with 0 and the end-point of the x-axis (say 100).
If F(0)=F(100), then F is constant.
Else F is not constant and I compute F(50).
If F(50) = F(0), then F is constant on [0,50] and I compute F(75) and so on.
Else if F(50) = F(100), then F is constant on [50,100] and I compute F(25) and so on.
Else I compute F(25) and F(75) and so on.
Is there any python librairy which would be useful to implement such an algorithm?
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I'm looking to locate the position of this purple circle and similiar situations for different datasets in which there is a (mainly) horizontal lag before the sensor starts gathering data.
Any ideas?
numpy.diff gives you the difference between each consecutive item in your array. It can be very useful but you may need to add some smoothing to prevent noise from giving false positives. Here is an easy smoothing function to use:
def moving_average(x, w):
return np.convolve(x, np.ones(w), 'valid') / w
(talken from here)
I suggest you plot np.diff(data) and see what that looks like. It will be much easier to find the purple point on that graph and it might even be easier yet to find it if you do np.diff twice.
For this single case, I would do:
purple_index = np.argmax(np.diff(data) < -1)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
In MATLAB, binofit returns the maximum likelihood estimate of the success of binomial probability distribution and confidence intervals.
statsmodels.stats.proportion.proportion_confint returns confidence intervals as well, but couldn't find a function for maximum likelihood estimate of the binomial probability distribution. Is there any function that you can suggest as a binofit function in MATLAB for python?
I think the function you suggested is good enough. I ran some test comparing Matlab binofit and Python statsmodels.stats.proportion.proportion_confint. The test was empyrical like testin 100K experiments like [phat,pci] = binofit(x,n,alpha) with min_conf,max_conf = proportion_confint(x,n,alpha=alpha,method='beta').
The RMSE bewteen confidence interval limits from Matlab and Python are below 5e-6 for values values of x and n between 0 and 10000. Tested with alpha=0.05 and 0.01.
I know this is not strict demonstrations but for my project I decided to consider the two estimates of confidence intervals as equivalent.
Try using one of these two libraries: statsmodels or scipy.
I do not know if it is exactly what you're looking for, but I hope you find it useful still.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I have a list of binary strings and two center strings which are not in the list.
I would like to classify that list around the center strings in order to create two clusters. A string of the list will be assigned to the cluster whose center is nearest to that string (hamming distance as metric).
I've seen that there are alghoritms like Neighbours Classifier, k-medoids, Affinity propagation, but all these procedure calculate centroids on their own; I have to use my center strings instead.
Any suggestion?
Perform 1-nearest neighbor classification using your centers only.
No need for anything special here. Just assign to the nearest center.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I have matrix differential equation diff(x) = A * x, x(0) = C, where:
x is 1 * N
A is N * N, and is a constant matrix.
I want to solve it with python. By the time I have found ways to get only approximate solutions, but I want to get an exact solution. What library can do it for me?
You can use sympy for symbolic mathematics in Python. In particular, look at sympy documentation on ODEs.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm very confused as to what np.exp() actually does. In the documentation it says that it: "Calculates the exponential of all elements in the input array." I'm confused as to what exactly this means. Could someone give me more information to what it actually does?
The exponential function is e^x where e is a mathematical constant called Euler's number, approximately 2.718281. This value has a close mathematical relationship with pi and the slope of the curve e^x is equal to its value at every point. np.exp() calculates e^x for each value of x in your input array.
It calculates ex for each x in your list where e is Euler's number (approximately 2.718). In other words, np.exp(range(5)) is similar to [math.e**x for x in range(5)].
exp(x) = e^x where e= 2.718281(approx)
In Python we can use the exp function from numpy (docs):
import numpy as np
ar=np.array([1,2,3])
ar=np.exp(ar)
print ar
outputs:
[ 2.71828183 7.3890561 20.08553692]