Python Forum
random matrix, with some special feature
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
random matrix, with some special feature
#2
from itertools import permutations
import random

rows = list(permutations([-1, 0, 1], 3))
matrix = np.array([random.choice(rows) for _ in range(1000)])
print(matrix)

if you wish you can pass matrix as argument to np.array()
Sorry, i misunderstood a bit

import random

rows = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 0, -1], [0, -1, 0], [-1, 0, 0]]
matrix = np.array([random.choice(rows) for _ in range(1000)])
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: random matrix, with some special feature - by buran - Aug-28-2018, 04:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  define a diagonal matrix from a matrix amalalaoui 1 2,379 May-15-2019, 01:12 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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