Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
y according to x1, x2
#1
Hello,

I used this code to obtain all the possibility of value between( -3 and 3 )for x1 and x2:

import numpy as np
import math
x1 = np.arange(-3.0, 3.0,0.1) 
x2 = np.arange(-3.0, 3.0,0.1)
X = np.array ([x1,x2]). T
My problem I don't obtain all the possibility in the space : for example [x1,x2]=[1 ,2]
or [x1,x2]= [2 ,1] .....

Please who have any idea to correct this.
Reply
#2
Look at itertools.product. That will give you all the combinations. You can then zip the output to transpose it into the x1 and x2 columns.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020