[SciPy-User] array creation

elmar werling elmar at net4werling.de
Wed Nov 11 14:14:23 EST 2015


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 at net4werling.de
> <mailto:elmar at 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 at scipy.org <mailto:SciPy-User at scipy.org>
>     https://mail.scipy.org/mailman/listinfo/scipy-user
>
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> https://mail.scipy.org/mailman/listinfo/scipy-user
>




More information about the SciPy-User mailing list