Hi there.
Anyone knows how to use numpy / scipy in order to solve this ?
* A is an array of shape (n,)
* X is a positive float number
* B is an array of shape (n,)
* O is an array of shape (n,) containing only zeros.
A.X  B = O
min(X)
thanks. 9 1789
On 20060717, TG <gi****@gmail.comwrote:
Hi there.
Anyone knows how to use numpy / scipy in order to solve this ?
* A is an array of shape (n,)
* X is a positive float number
* B is an array of shape (n,)
* O is an array of shape (n,) containing only zeros.
A.X  B = O
min(X)
Are we solving for A, B or X? And what do you mean by min(X)?
If we're solving for X there will be many combinations of A and B for
which there is no solution.
Ben C wrote:
On 20060717, TG <gi****@gmail.comwrote:
Hi there.
Anyone knows how to use numpy / scipy in order to solve this ?
* A is an array of shape (n,)
* X is a positive float number
* B is an array of shape (n,)
* O is an array of shape (n,) containing only zeros.
A.X  B = O
min(X)
Are we solving for A, B or X? And what do you mean by min(X)?
If we're solving for X there will be many combinations of A and B for
which there is no solution.
Sorry for the poor explanation. I'm trying to put it clear now.
i've got A and B. I'm looking for X. I made a mistake in my equation
:/
It's more like :
A.X  B >= O
Well, maybe it will be much more simple if I explain the underlying
problem :
I have an array of N dimensions (generally 2).
 A first calculation gives me a set of integer coordinates inside this
array, which I will call the point W.
 After several other calculations, I've got a set of coordinates in
this N dimensional space that are floating values, and not bound to the
limits of my original Narray. This is the point L.
What I want to do is to translate the point L along the vector LW in
order to get a point L' which coordinates are inside the original
Ndimensional array. Then it will be easy to get the closest integer
coordinates from L'.
I'm not sure this is clear ... pretty hard to talk about maths in
english.
TG wrote:
Hi there.
Anyone knows how to use numpy / scipy in order to solve this ?
* A is an array of shape (n,)
* X is a positive float number
* B is an array of shape (n,)
* O is an array of shape (n,) containing only zeros.
A.X  B = O
min(X)
thanks.
TG wrote:
Hi there.
Anyone knows how to use numpy / scipy in order to solve this ?
* A is an array of shape (n,)
* X is a positive float number
* B is an array of shape (n,)
* O is an array of shape (n,) containing only zeros.
A.X  B = O
min(X)
thanks.
TG wrote:
Hi there.
Anyone knows how to use numpy / scipy in order to solve this ?
* A is an array of shape (n,)
* X is a positive float number
* B is an array of shape (n,)
* O is an array of shape (n,) containing only zeros.
A.X  B = O
min(X)
thanks.
In article <11*********************@b28g2000cwb.googlegroups. com>,
TG <gi****@gmail.comwrote:
>Hi there.
Anyone knows how to use numpy / scipy in order to solve this ?
* A is an array of shape (n,) * X is a positive float number * B is an array of shape (n,) * O is an array of shape (n,) containing only zeros.
A.X  B = O min(X)
thanks.
In general, no X solves the equality, so it's easy to minimize X.
If A is a nonzero positive multiple of B, exactly one X solves
the equality, so it's again easy to minimize.
If A and B vanish, choose X as the smallest positive float.
I suspect you intended a slightly different problem. It's hard
to guess what it is.
On 20060717, TG <gi****@gmail.comwrote:
>
Ben C wrote:
>On 20060717, TG <gi****@gmail.comwrote:
Hi there.
Anyone knows how to use numpy / scipy in order to solve this ?
* A is an array of shape (n,)
* X is a positive float number
* B is an array of shape (n,)
* O is an array of shape (n,) containing only zeros.
A.X  B = O
min(X)
Are we solving for A, B or X? And what do you mean by min(X)?
If we're solving for X there will be many combinations of A and B for which there is no solution.
Sorry for the poor explanation. I'm trying to put it clear now.
i've got A and B. I'm looking for X. I made a mistake in my equation :/
It's more like :
A.X  B >= O
How about this:
from random import *
def solve(A, B):
return reduce(max, (float(b) / a for a, b in zip(A, B)))
def test():
A = [random() for i in range(4)]
B = [random() for i in range(4)]
x = solve(A, B)
for a, b in zip(A, B):
print a, b, a * x  b
test()
This only works if all elements of both A and B are positive.
Well, maybe it will be much more simple if I explain the underlying
problem :
I have an array of N dimensions (generally 2).
 A first calculation gives me a set of integer coordinates inside this
array, which I will call the point W.
Is this an array of points, or an array of values, that contains only
one point?
 After several other calculations, I've got a set of coordinates in
this N dimensional space that are floating values, and not bound to the
limits of my original Narray. This is the point L.
What I want to do is to translate the point L along the vector LW
Do you mean the vector L  W? (LW is a scalar, assuming dot product).
in order to get a point L' which coordinates are inside the original
Ndimensional array. Then it will be easy to get the closest integer
coordinates from L'.
I'm not sure this is clear ... pretty hard to talk about maths in
english.
Not very clear to me I'm afraid!
TG wrote:
Hi there.
Anyone knows how to use numpy / scipy in order to solve this ?
* A is an array of shape (n,)
* X is a positive float number
* B is an array of shape (n,)
* O is an array of shape (n,) containing only zeros.
A.X  B = O
min(X)
thanks.
Looks like an incorrectly specified degenerate linear least squares
problem. The function numpy.linalg.linear_least_squares might be able
to do what you want.
Carl Banks
TG wrote:
Sorry for the poor explanation. I'm trying to put it clear now.
i've got A and B. I'm looking for X. I made a mistake in my equation
:/
It's more like :
A.X  B >= O
Well, maybe it will be much more simple if I explain the underlying
problem :
I have an array of N dimensions (generally 2).
 A first calculation gives me a set of integer coordinates inside this
array, which I will call the point W.
 After several other calculations, I've got a set of coordinates in
this N dimensional space that are floating values, and not bound to the
limits of my original Narray. This is the point L.
What I want to do is to translate the point L along the vector LW in
order to get a point L' which coordinates are inside the original
Ndimensional array. Then it will be easy to get the closest integer
coordinates from L'.
I see. You have a simple linear programming problem. These can be
tricky in general. Because you only have one variable, it's probably
ok to use brute force. Try this:
given X, A, and B:
E = A*XB
C = numpy.where(E<0,B/A,X)
X = min(C)
This assumes that you've designed the problem such that B/A would be
less than X where A*XB<0 (if the opposite were true then of course
you'd need max(C)).
Carl Banks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: greg.smith 
last post by:
Hi there,
I've been trying to solve this different via numerical methods(C
programming) and it's
driving me crazy....
I can't post my code because it's simply one big mess and doesn't work.
...

by: Anatoly 
last post by:
Hi All !!!
Can anyone give me link to the C++ source or to the compiled program unit
(compatible with Microsoft VC++), designed for the solving of the algebraic
linear systems with rare matrices...

by: Michael MacDonald 
last post by:
I have written a simple program that calculates a running $ total. This
program uses a checkbox to acknowledge that that version of the ticket
is desired and it checks the Qty box to see how many...

by: 116Rohan 
last post by:
I have been trying to figure out how to solve uneqaulity problems
I have two equations which I am trying to figure out
What values of n will make
8n^2 < 64 * n * Lg n
What I am trying to find...

by: Thomas 
last post by:
Hi,
I've to solve a system of linear equations and inequations in C++. Are
there (free) librarys for that topic?
Regards,
Thomas

by: mismis 
last post by:
HELP!..PLEASE..i have a project that asks to write a C++ program solving for the root of the equation (x*x*x)(x*x)(9x)+(9) ........huhuhu..please help..i really need to pass..please..

by: Trev17 
last post by:
Hello, I am new to C++ and i have tried for several hours to make a program my teacher has given me as a lab. Here is the Lab question:
the roots of the quadratic equation ax^2 + bx + c = 0, a...

by: trashman.horlicks 
last post by:
Hi,
A few months ago, I saw an equation parser, written in c#, and using
regular expressions (I think!), but now I cannot recall where I saw
it if anyone saw anything like this, could they please...

by: Deviate 
last post by:
Hi again guys :)
Ok i have this problem, i need to solve the equation phi(x) = 0.1
(where phi is the area under the gaussian normal distribution function)
apparently im supposed to solve it...

by: Rina0 
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...

by: erikbower65 
last post by:
Using CodiumAI's pragent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install g codiumai' in the terminal.
2. Connect to...

by: kcodez 
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game  Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...

by: DJRhino1175 
last post by:
When I run this code I get an error, its Runtime error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this 
If...

by: Rina0 
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...

by: DJRhino 
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...

by: lllomh 
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{

by: Mushico 
last post by:
How to calculate date of retirement from date of birth

by: DJRhino 
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
 