Questions tagged [scipy-optimize-minimize]
446 questions
0
votes
1 answer
Marginal Likelihood optimization with python
I'm trying to optimize the marginal likelihood to estimate parameters for a Gaussian process regression.
So i defined the marginal log likelihood this way:
def marglike(par,X,Y):
l,sigma_n = par
n = len(X)
dist_X = (X.T - X)**2
k =…

Pasquale Russo
- 15
- 4
0
votes
0 answers
Maximizing log-likelihood function with python
i'm trying to maximize the log-likelihood function with python, using the funcion "minimize" from scipy.optimize.
declaring the log-likelihood function this way:
def like(mu,sigma,x):
l = -(len(x)/2)*np.log(2*np.pi) -…

Pasquale Russo
- 15
- 4
0
votes
1 answer
Scipy fsolve solving an equation with specific demand
Below a sample of code consists an equation, it uses scipy.fsolve to find zero with x-axis,
1- How to run fsolve and ask to search within a specific interval f.ex. -75 and 75?
2- Sometimes the demand is to find x value when result becomes 2000, how…

Pavel.D
- 561
- 1
- 15
- 41
0
votes
1 answer
Python-Apply Asset value and volatility calculation function for each row in csv file
I imported a csv file and calculate asset value and volatility of a stock.
df = pd.read_csv (r'test.csv')
df['ret_col'] = np.log(df.price) - np.log(df.price.shift(1))
df['sigma_e'] = np.std(df.ret_col)
T = 1
My function is:
def equation(x):
d1…

Hoang Yen
- 1
- 1
0
votes
1 answer
scipy.optimize.least_squares, LinearOperator for argument 'jac'
I'm trying to understand the documentation on the scipy.optimize.least_squares function:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.least_squares.html
The possibilities for inputs are a bit messy, and the documentation is…

Andi Bauer
- 101
- 1
0
votes
0 answers
minimize with positive constraints returns zero parameters
I am using scipy.optimize.minimize to minimize a function with l2 norm constraints and non-negative constraints on the computed parameters (some related links 1, 2, 3). More specifically, I have tried
con = ({'type': 'ineq', 'fun': lambda x: x},…

Thoth
- 993
- 12
- 36
0
votes
2 answers
Fastest way to minimize sum of squares involving large weighted matrices
I need to minimize a sum of squares between two large (10000 by 40000) matrices: Σ(X-A)^2 where
X is a concatenation of two matrices (10000 by 20000) and each segment is weighted (W) individually, see pic for inner function..
There is also a…

user1361488
- 83
- 7
0
votes
1 answer
Minimize a function by multiple variables and boundaries using scipy.optimize
I want to optimize this function:
def cost_func(adg_guess,wave_guess,wave_opt,C0,C1,S):
ka=0
for wave in wave_guesse:
ka=ka+(adg_guess[find(wave,wave_guess)]-C0*np.exp(-S*(wave-440))-C1)^2
return ka
from scipy.optimize import…

lifeodyssey
- 15
- 6
0
votes
1 answer
Minimize two variables with scipy optimize
I want to fit two learning rates (alpha), one for the first half of the data and one for the second half of the data. I was able to do this for just one learning but am running into errors when attempting to fit two.
These functions work when…

beni
- 1
- 1
- 2
0
votes
1 answer
Problem in linear constraints of scipy. All the elements of population is getting rejected
I am using scipy differential evolution. I have to set the following linear constraints.
0

Raihan Ul Islam
- 35
- 3
0
votes
0 answers
Intercomparison of SciPy minimisation algorithms
I've recently begun to use the scipy.optimize minimisation library, and am experimenting with different algorithms.
I see there's good documentation for each algo individually on the docs page, but does anybody know of any intercomparison work…

Robbie Mallett
- 131
- 1
- 11
0
votes
0 answers
scipy minimize with SLSQP method: spark implementation?
as the title suggests, is there any repository where somebody has implemented this kind of constrained optimization method in (py)Spark?
The thing is the project I am working on has got several steps and, while nearly all of them can be done…

Asher11
- 1,295
- 2
- 15
- 31
0
votes
1 answer
Scipy.optimize minimize function behaving strangely
I am currently using Python and am getting strange results when using Scipy.optimize - specifically the minimize function. Everything up to def optimize_portfolio(initial,returns,rf) seems to run fine. The first few iterations of minimizing run…

Charmalade
- 645
- 1
- 6
- 14
0
votes
1 answer
optimizie.minimize using CG
I have been using the following code:
options = {'maxiter':50, 'disp':True}
res = optimize.minimize(
fun=lrCostFunction,
x0=theta_k,
args=(X, y_k, lambda_),
method='CG',
options=options
)
And that gives me…

Kais Hasan
- 111
- 7
0
votes
1 answer
Math domain error from Scipy minimize SLSQP constrained optimization
I am trying to minimize the function
20A + 40B subject to 120 = 100sqrt(A) + 150sqrt(B)
I wrote the following code and used it with other functions and it worked. But this time it doesn't with math.sqrt.
from scipy.optimize import minimize
from…

Hogwash MRA
- 15
- 5