MathGroup Archive 1998

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

Search the Archive

Re: lattice definition: help


  • To: mathgroup@smc.vnet.net
  • Subject: [mg11206] Re: lattice definition: help
  • From: calvitti@calvitti.ces.cwru.edu ()
  • Date: Mon, 2 Mar 1998 23:10:59 -0500
  • In-Reply-To: Christofer Edling's message of 25 Feb 1998 01:08:39 -0500
  • Organization: Case Western Reserve University
  • References: <6d0ch7$2no@smc.vnet.net>


    C> I wish to generate an n*n lattice with the following
    C> characteristics:
    C> 1. Each cell in the lattice can be in one out of three possible
    C> states, i.e. A,B,C.  2. The distribution of states across the
    C> whole lattice is defined by user input, i.e. 30% A's, 20% B's,
    C> 50% C's. 3. Given the defined distribution, each cell in the
    C> lattice should be randomly assigned a state (A,B or C).

Random[] generates uniformly distributed r.v. in the range [0,1], so you
can map that segment into your desired values like this:

In[3]:= f[x_] := A /; 0 <= x < 0.2

In[4]:= f[x_] := B /; 0.2 <= x < 0.5

In[5]:= f[x_] := C /; 0.5 <= x < 1

then you can map f[] across the n by n table

In[9]:= tmp = Table[Random[],{i,1,4},{j,1,4}];

In[11]:= Map[f,tmp,{2}] //MatrixForm

Out[11]//MatrixForm= C   C   C   C

                     A   A   A   C

                     C   C   B   B

                     B   C   B   C


 +---------------------------------+
 |          Alan Calvitti          |
 |       Control Engineering       |
 | Case Western Reserve University |
 +---------------------------------+



  • Prev by Date: re: A Difficult Optimization Problem!
  • Next by Date: Copying from Excel 97
  • Prev by thread: Re: lattice definition: help
  • Next by thread: Re: lattice definition: help