MathGroup Archive 2007

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

Search the Archive

Re: Create random binary images


Tara.Ann.Lorenz at gmail.com wrote:

> 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?

One possible way is to use *RandomChoice* with a list of weights 
associated to your values. For instance,

data = RandomChoice[{0.95, 0.05} -> {0, 1}, {30, 30}];

ArrayPlot[data]

Regards,
-- 
Jean-Marc


  • Prev by Date: Re: Create random binary images
  • Next by Date: Re: Create random binary images
  • Previous by thread: Re: Create random binary images
  • Next by thread: Re: Create random binary images