[Numpy-discussion] Numpy newbie question: matrix creation
Stéfan van der Walt
stefan at sun.ac.za
Wed Sep 25 08:04:41 EDT 2013
On Wed, Sep 25, 2013 at 9:06 AM, Edmondo Porcu <edmondo.porcu at gmail.com> wrote:
> I am a Newbie with Numpy and I would need some advice on how to create a
> matrix with certain characteristics :
> - Every entry should be minimum 0 maximum 1 with a step of 0.1 (legal
> values are 0,0.1,0.2,0.3 etc)
You can generate random integers between 0 and 10, and divide them by 10:
np.random.random_integers(0, 10, (5, 5)) / 10.
> - Only the rows where the sum is 1 must be kept
I'm not sure I understand the exact structure you describe. Perhaps
an example would help.
More information about the NumPy-Discussion