Mathematica 9 is now available
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: [mg83724] Re: [mg83637] Create random binary images
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Thu, 29 Nov 2007 06:21:25 -0500 (EST)
  • References: <200711271105.GAA15599@smc.vnet.net>

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
>  
>
Use RandomChoice. For example:

RandomChoice[{5, 95} -> {1, 0}, {30, 30}]

Carl Woll
Wolfram Research


  • Prev by Date: Re: Convert nxn matrix to a column vector with (n^2) elements
  • Next by Date: Re: Mathematica 6 and system of matrix and scalar ODEs in NDSolve:
  • Previous by thread: Create random binary images
  • Next by thread: Re: Create random binary images