Hi, is there a function foo(ncols, min, max, delta) in mumpy/scipy to create an array such as 0 100 0 0 0 100 10 90 0 10 80 10 10 70 20 10 60 30 10 50 40 10 40 50 10 30 60 20 20 70 20 10 80 20 0 90 20 80 0 ... ... ... 90 10 0 90 0 10 100 0 0 Any help or link is welcome Elmar
Can you specify a little more clearly what you're looking for? I'm not seeing the pattern. On Wed, Nov 11, 2015 at 1:12 PM, elmar werling <elmar@net4werling.de> wrote:
Hi,
is there a function foo(ncols, min, max, delta) in mumpy/scipy to create an array such as
0 100 0 0 0 100 10 90 0 10 80 10 10 70 20 10 60 30 10 50 40 10 40 50 10 30 60 20 20 70 20 10 80 20 0 90 20 80 0 ... ... ... 90 10 0 90 0 10 100 0 0
Any help or link is welcome
Elmar
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org https://mail.scipy.org/mailman/listinfo/scipy-user
I need a generalized function foo(ncols, min, max, delta) for # two component mixing ratios (ncols=2, min=0, max=1, delta=0.1) for x1 in np.arange(0.0, 1.05, 0.1): x2 = 1.0 - x1 print (x1, x2, ' = ', x1+x2) # three component mixing ratios (ncols=3, min=0, max=1, delta=0.1) for x1 in np.arange(0.0, 1.05, 0.1): for x2 in np.arange(1.0 - x1, -0.01, -0.1): x3 = 1.0 - x1 - x2 print(x1, x2, x3, ' = ', x1+x2+x3) # four component mixing ratios (ncols=3, min=0, max=1, delta=0.1) for x1 in np.arange(0.0, 1.05, 0.1): for x2 in np.arange(1.0 - x1, -0.01, -0.1): for x3 in np.arange(1.0 - x1 - x2, -0.01, -0.1): x4 = 1.0 - x1 - x2 - x3 print(x1, x2, x3, x4, ' = ', x1+x2+x3+x4) On 11.11.2015 19:44, Max Shron wrote:
Can you specify a little more clearly what you're looking for? I'm not seeing the pattern.
On Wed, Nov 11, 2015 at 1:12 PM, elmar werling <elmar@net4werling.de <mailto:elmar@net4werling.de>> wrote:
Hi,
is there a function foo(ncols, min, max, delta) in mumpy/scipy to create an array such as
0 100 0 0 0 100 10 90 0 10 80 10 10 70 20 10 60 30 10 50 40 10 40 50 10 30 60 20 20 70 20 10 80 20 0 90 20 80 0 ... ... ... 90 10 0 90 0 10 100 0 0
Any help or link is welcome
Elmar
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> https://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org https://mail.scipy.org/mailman/listinfo/scipy-user
with the following pattern the pattern is 0 100 0 0 0 100 10 90 0 10 80 10 10 70 20 10 60 30 10 50 40 10 40 50 10 30 60 10 20 70 10 10 80 10 0 90 20 80 0 20 70 10 20 60 20 20 50 30 20 40 40 20 30 50 20 20 60 20 10 70 20 0 80 30 70 0 30 60 10 30 50 20 30 40 30 30 30 40 30 20 50 30 10 60 30 0 70 ... ... ... On 11.11.2015 19:44, Max Shron wrote:
Can you specify a little more clearly what you're looking for? I'm not seeing the pattern.
On Wed, Nov 11, 2015 at 1:12 PM, elmar werling <elmar@net4werling.de <mailto:elmar@net4werling.de>> wrote:
Hi,
is there a function foo(ncols, min, max, delta) in mumpy/scipy to create an array such as
0 100 0 0 0 100 10 90 0 10 80 10 10 70 20 10 60 30 10 50 40 10 40 50 10 30 60 20 20 70 20 10 80 20 0 90 20 80 0 ... ... ... 90 10 0 90 0 10 100 0 0
Any help or link is welcome
Elmar
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> https://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org https://mail.scipy.org/mailman/listinfo/scipy-user
Elmar: You could use smth like this.... import itertools as itt import numpy as np def foo(ncol=1, start=0, end=10, delta=0.1): if ncol==1: return np.arange(start, end, delta) else: ranges = ncol * [np.arange(start, end, delta), ] for z in itt.product(*ranges): yield z for (x1, x2) in foo(ncol=2): print(x1, x2) This is not exactly what you need but might help. Cheers 2015-11-11 14:17 GMT-05:00 elmar werling <elmar@net4werling.de>:
with the following pattern
the pattern is
0 100 0 0 0 100 10 90 0 10 80 10 10 70 20 10 60 30 10 50 40 10 40 50 10 30 60 10 20 70 10 10 80 10 0 90 20 80 0 20 70 10 20 60 20 20 50 30 20 40 40 20 30 50 20 20 60 20 10 70 20 0 80 30 70 0 30 60 10 30 50 20 30 40 30 30 30 40 30 20 50 30 10 60 30 0 70 ... ... ...
On 11.11.2015 19:44, Max Shron wrote:
Can you specify a little more clearly what you're looking for? I'm not seeing the pattern.
On Wed, Nov 11, 2015 at 1:12 PM, elmar werling <elmar@net4werling.de <mailto:elmar@net4werling.de>> wrote:
Hi,
is there a function foo(ncols, min, max, delta) in mumpy/scipy to create an array such as
0 100 0 0 0 100 10 90 0 10 80 10 10 70 20 10 60 30 10 50 40 10 40 50 10 30 60 20 20 70 20 10 80 20 0 90 20 80 0 ... ... ... 90 10 0 90 0 10 100 0 0
Any help or link is welcome
Elmar
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org <mailto:SciPy-User@scipy.org> https://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org https://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org https://mail.scipy.org/mailman/listinfo/scipy-user
-- Sasha
On Wed, Nov 11, 2015 at 6:12 PM, elmar werling <elmar@net4werling.de> wrote:
Hi,
is there a function foo(ncols, min, max, delta) in mumpy/scipy to create
an array such as
0 100 0 0 0 100 10 90 0 10 80 10 10 70 20 10 60 30 10 50 40 10 40 50 10 30 60 20 20 70 20 10 80 20 0 90 20 80 0 ... ... ... 90 10 0 90 0 10 100 0 0
Any help or link is welcome
I answered a very similar question a couple of years ago: https://mail.scipy.org/pipermail/numpy-discussion/2013-September/067841.html -- Robert Kern
thank you for help import itertools import numpy as np ncols = 3 start, stop, step = 0.0, 1.0, 0.2 iterable = np.arange(start, stop+step/2, step) mixing_ratios = itertools.product(iterable, repeat=ncols) mixing_ratios = [i for i in mixing_ratios if np.isclose(sum(i), 1.0)] On 11.11.2015 19:12, elmar werling wrote:
Hi,
is there a function foo(ncols, min, max, delta) in mumpy/scipy to create an array such as
0 100 0 0 0 100 10 90 0 10 80 10 10 70 20 10 60 30 10 50 40 10 40 50 10 30 60 20 20 70 20 10 80 20 0 90 20 80 0 ... ... ... 90 10 0 90 0 10 100 0 0
Any help or link is welcome
Elmar
participants (4)
-
elmar werling -
Max Shron -
Oleksandr Huziy -
Robert Kern