Reputation: 898
I need some help starting this please as I've just been staring at this blankly for quite a while now
from itertools import permutations
import numpy as np
limit = np.arange(0, 1, 0.01)
a = ?
b = ?
c = ?
My intention is to iterate through each permutation of (a, b, c) where each is a value within in the limit. So I can test a function I'm working with to find the best possible outcome
Upvotes: 0
Views: 111
Reputation: 7590
This is a pretty direct application of the permutations iterator
limit = np.arange(0,1,0.01)
for a,b,c in permutations(limit,3):
# do something with a, b, and c
The permutations
function will go through all 3 item permutations of the values in limit
and assign those values to a
,b
, and c
.
Make sure that you realize that there are quite a few permutations to loop through. As limit
consists of 100 values, there will be 970,200 individual permutations, so if the operations you wish to do with these values take much time, your code might take a while to run.
See here in the official python documentation for details on the permutations function.
Upvotes: 1