MathGroup Archive 2003

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

Search the Archive

RE: discrete frequency distribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43116] RE: [mg43102] discrete frequency distribution
  • From: "Scott Guthery" <sguthery at mobile-mind.com>
  • Date: Wed, 13 Aug 2003 07:49:49 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I'm very new to Mathematica so take the following with a large grain of salt ... there are probably much better ways ...
 
Discrete[l_] := Module[{n = Length[l], total=0}, prob=Array[p, {n}];  For[i = 1, i <= n, total += l[[i]]; i++]; For[p[1] = l[[1]]/total; i = 2,  i <= n,  p[i] = p[i-1]+l[[i]]/total;i++];   x = Random[]; For[i = 1, i <= n, If[p[i]>x,Break[]];i++ ]; i]

	-----Original Message----- 
	From: Jan Schmedes [mailto:schmedes at rz.uni-potsdam.de] 
To: mathgroup at smc.vnet.net
	Sent: Tue 8/12/2003 4:43 AM 
	To: mathgroup at smc.vnet.net 
	Cc: 
	Subject: [mg43116] [mg43102] discrete frequency distribution
	
	

	dear group,
	
	i have a set of points which describe a varaible and his frequency, e.g.
	counting the age of N people in "age-bins" 0-10 a,10-20 a,20-30 a,... .
	Given this discrete frequency distribution i want to produce random
	numbers.
	How could i do this?
	
	Thank you for help
	
	Jan Schmedes
	
	


  • Prev by Date: Re: Mathematica 5.0: small change in fundamental behaviour.
  • Next by Date: Nonlinear fit for a non-differentiable function
  • Previous by thread: discrete frequency distribution
  • Next by thread: Re: discrete frequency distribution