From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Distance randomly generated with density function
Date: Sat, 19 Nov 2011 13:57:10 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 8
Message-ID: <ja8cjm$11f$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1321711030 1071 (19 Nov 2011 13:57:10 GMT)
NNTP-Posting-Date: Sat, 19 Nov 2011 13:57:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3189466
Xref: comp.soft-sys.matlab:749846

Hello everyone, 

I have the density function f(d)=2d, where d is the distance of a user and 0<=d=<1 (kilometers). My system has 64 users and i want the distance d of a user to be generated randomly with the above density function. I have programmed a code but i believe it's not responding in my needs. Can someone explain me how can i simulate this ? My code is following.

PROB=[.01 .03 .05 .07 .09 .11 .13 .15 .17 .19] ;
temporary = randp(PROB,N);