Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: Create random binary images

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83663] Re: Create random binary images
  • From: dh <dh at metrohm.ch>
  • Date: Wed, 28 Nov 2007 05:21:52 -0500 (EST)
  • References: <figtob$f90$1@smc.vnet.net>


Hi Tara,

in version 6 we have RandomSample that can take weights. We may choose 

this to get one number with the weights you want. Using "Table" we then 

get the array:

t=Table[RandomSample[{0.95,0.05}->{0,1},1][[1]],{30},{30}];

we can visualize this:

Graphics[Raster[t]] //Show

hope this helps, Daniel



Tara.Ann.Lorenz 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

> 




  • Prev by Date: Re: Stream programming
  • Next by Date: Re: Trying to create a clustered StackedBarChart
  • Previous by thread: Re: Create random binary images
  • Next by thread: Re: Create random binary images