MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Create random binary images

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83710] Re: Create random binary images
  • From: Norbert Marxer <marxer at mec.li>
  • Date: Wed, 28 Nov 2007 05:49:22 -0500 (EST)
  • References: <figtob$f90$1@smc.vnet.net>

On 27 Nov., 12:06, Tara.Ann.Lor... at gmail.com wrote:
> Hello,
>
> I am trying to create several random binary images of 30x30.  I want
> the outputs to be 1's and 0's, with 5% of the outputs being 1's.  Any
> ideas on how to code this in Mathematica?
>
> Thanks!
> Tara

Hello

The following will do what you want:

     Table[RandomChoice[{0.95, 0.05} -> {0, 1}], {30}, {30}]


Best Regards
Norbert Marxer


  • Prev by Date: Convert nxn matrix to a column vector with (n^2) elements
  • Next by Date: Re: Stream programming
  • Previous by thread: Re: Create random binary images
  • Next by thread: Re: Create random binary images