Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe24.iad.POSTED!7564ea0f!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Organization: Canada Eat The Cookie Foundation
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: Random matrix with zeros and ones and twos
References: <7946648.1226342494201.JavaMail.jakarta@nitrogen.mathforum.org> <20513365.1226348574762.JavaMail.jakarta@nitrogen.mathforum.org>
In-Reply-To: <20513365.1226348574762.JavaMail.jakarta@nitrogen.mathforum.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 32
Message-ID: <S81Sk.730$Yu5.290@newsfe24.iad>
NNTP-Posting-Host: 24.79.146.116
X-Complaints-To: internet.abuse@sjrb.ca
X-Trace: newsfe24.iad 1226350258 24.79.146.116 (Mon, 10 Nov 2008 20:50:58 UTC)
NNTP-Posting-Date: Mon, 10 Nov 2008 20:50:58 UTC
Date: Mon, 10 Nov 2008 14:51:16 -0600
Xref: news.mathworks.com comp.soft-sys.matlab:500077


Tim Smith wrote:

> Thanks for the reply

> I need to create a 100 x 100 matrix filled a% with zeros, b% with ones and c%
> twos a+b+c=100%. The distribution should be random.

In that case, use the code I gave before. If it comes out too slow, then you can
speed it up afterwards.

However, I do caution you that "the distribution should be random" is insufficiently
precise. When you speak of randomness, you need to speak of particular probability
distributions.

Consider, for example, golfers hitting onto a green. They might hit and have the
ball roll into the hole (a 0); they might need one more stroke to get into the
cup (a 1), or they might need two [or more] strokes to get into the cup (a 2).
In each case, the -exact- location their ball first touches down on the
green is "random" (e.g., affected by micro-gusts of wind), and first touching
down at any particular place does not guarantee a 0, 1, or 2 -- but the
-probability- (over the long term, over sufficient shots by decent golfers)
over the long term of the "result" being 0, 1, or 2 is not evenly distributed
across the green. You -might- land far from the cup and have the ball roll directly
in anyhow, and you -might- land a fraction of an inch from the cup and have a bad
bounce and need 2 shots to get it in. You can have a probability distribution which
is not symmetric or not smooth, and yet the distribution would still be "random".

-- 
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?