title: How do I program a 2D array of random numbers so it follows a certain rules in python
body: <p>I am trying to create a table of propabilities which follows a rule that:
  Starting from a top row the propability is the highest in first column and all consecutive propabilities in the row need to decrese.
  For the second row the propability in the first colum is lower than in the second column and then it decreses again.
  For the third row the highest is in the third place. And so on ...</p>
  <p>Additionally sum of all values in each row needs to be 1.</p>
  <p>I have already solved the normalization criterion:</p>
  <ol>
  <li>Generate random nums</li>
  <li>Find their sum</li>
  <li>Devide each by the sum</li>
  </ol>
  <p>But i don´t know how to do the other one.
  I thought about generating values and inserting them diagonoally and each time i switch to next diagonall I change the range from which I choose random nums but I feel like there is a better solution.</p>
  <p>If someone can just push me into the right direction would help alot.</p>
  <p>Here is what i have:</p>
  <pre><code>import numpy as np
  import random as rand
  
  
  class DataGen:
      def __init__(self, processDuration, states, actions):
          self.processDuration = processDuration
          self.states = states
          self.actions = actions
  
          self.propabilityTable = np.empty(len(self.states), dtype=np.ndarray)
          self.CreateTable()
          self.RandomDataGen()
  
      def CreateTable(self):
          for i in range(len(states)):
              self.propabilityTable[i] = np.zeros((len(self.actions), len(self.states)))
  
  
      def RandomDataGen(self):
          for i in range(len(states)):
              for j in range(len(actions)):
                  sum = 0
                  for k in range(len(states)):
                      randNum = rand.random()
                      sum += randNum
                      self.propabilityTable[i][j][k] = randNum
                  for k in range(len(states)):
                      self.propabilityTable[i][j][k] = self.propabilityTable[i][j][k]/sum
                  # testSum = 0 
                  # for k in range(len(states)):
                  #     testSum += self.propabilityTable[i][j][k]
                  #     print(testSum)
  
  
  states = np.array([0, 1])
  actions = np.array([10, 20, 30])
  generator = DataGen(2, states, actions)
  print(generator.propabilityTable)
  
  </code></pre>