What exactly does numpy.exp() do? [closed] - python

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]

Related

How to find steps in a stepwise curve? [closed]

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?

Is there a function in python that might allow me to identify the location of this purple circle? [closed]

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)

Solving an optimization problem with variable powers [closed]

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
Can anyone point me to a tool (preferably in python or c++) to solve an optimization problem where in the objective has power fractions such as :
Maximize x1^0.2 + x2^ 0.3 + x3^0.4
Thanks
I think this should be possible in python with scipy.optimize
Since it allows fractional exponentiation
4**0.5 = 2
4**0.2 = 1.3195079
and the objective function is defined as a plain python function.

Python equivalent for MATLAB binofit [closed]

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.

python matrix linear differential equation [closed]

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.

Categories