vendredi 10 juillet 2015

How to generate a set of random number with two sum

I'm trying to use javascript to implement the inside-outside algorithm of PCFG. But I have porblem generating a set of random data.

Assume that I need 10 random number, I need:

  1. the sum of first 5 number is 1 and sum the last 5 number also 1;
  2. the sum of the 3rd, 4th, 5th, 8th, 9th 10th is 1;

I have no idea how may i do this.

Currently, i could only implement one of the two point. Thank you all.




Aucun commentaire:

Enregistrer un commentaire