Re: Bell shaped random number generation
From: Art Kendall (Art_at_DrKendall.org)
Date: 09/28/04
- Next message: Roger Sherman: "Determining Confidence Interval"
- Previous message: strgh_at_mimosa.csv.warwick.ac.uk: "Re: Correlation of X with XY ?"
- In reply to: Harish: "Bell shaped random number generation"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 28 Sep 2004 14:01:13 GMT
A lot depends on how precisely you want to restrict the range, and how
closely you want to approximate the normal. SPSS has dozens of
distribution related functions. The example syntax below show the use of 3.
Cut, paste, and run the syntax below to see how they work.
You can cut and paste from the data window, or list the values and
cut-and paste, save as a text file, or as an Excel file, etc.
The uniform will stay in the desired range, the normal will have the
desired shape, the beta will sort of do both but not quite.
new file.
* this program generates 2000 cases with 3 differently distributed
variables.
set seed = 200409281.
input program.
loop #i = 1 to 2000.
compute x_uniform = rnd(rv.uniform(0,100)).
compute x_normal = rv.normal(50,15).
compute x_beta = rnd(100*rv.beta(2,2.5)).
end case.
end loop.
end file.
end input program.
formats x_uniform x_normal x_beta (f8.4).
descriptives variables = x_uniform x_normal x_beta
/statistics = all.
Art
Art@DrKendall.org
Social Research Consultants
University Park, MD USA
(301) 864-5570
Harish wrote:
> Hello,
> I need to write a computer program in which I need to get random
> numbers in a range, that follow an approximation of a bell curve. I
> tell the program that the average is say 20 and also say that most of
> values lie between 15 & 25.
> The range of the values is between 0,100. I have been suggested that I
> would need to look at beta distribution to generate such numbers but I
> could not figure out how to do it.
>
> I would be thankful to you if anyonce can provide any further input in
> this regard
>
> Thanks
> Harish
- Next message: Roger Sherman: "Determining Confidence Interval"
- Previous message: strgh_at_mimosa.csv.warwick.ac.uk: "Re: Correlation of X with XY ?"
- In reply to: Harish: "Bell shaped random number generation"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|