Modified random distribution: Difference between revisions

Added R: The only solution with a vertical histogram?
(Added R: The only solution with a vertical histogram?)
Line 757:
0.87, 5422, 1039: ##################################
0.93, 6205, 783: #######################################</pre>
=={{header|R}}==
 
Although it may not be immediately obvious, both modifier and gen are equivalent to the corresponding functions in the task.
<lang R>library(NostalgiR) #For the textual histogram.
modifier <- function(x) 2*abs(x - 0.5)
gen <- function()
{
repeat
{
random <- runif(2)
if(random[2] < modifier(random[1])) return(random[1])
}
}
data <- replicate(100000, gen())
NostalgiR::nos.hist(data, breaks = 20, pch = "#")</lang>
{{out}}
<pre>> NostalgiR::nos.hist(data, breaks = 20, pch = "#")
10000 +--+---------------------+---------------------+----------------------+---------------------+---------------------+--+
| # |
| # # |
| # # |
| # # # # |
| # # # # |
8000 + # # # # +
| # # # # |
| # # # # # # |
| # # # # # # |
| # # # # # # # # |
F | # # # # # # # # |
r 6000 + # # # # # # # # +
e | # # # # # # # # # # |
q | # # # # # # # # # # |
u | # # # # # # # # # # |
e | # # # # # # # # # # # # |
n 4000 + # # # # # # # # # # # # +
c | # # # # # # # # # # # # # |
y | # # # # # # # # # # # # # # |
| # # # # # # # # # # # # # # |
| # # # # # # # # # # # # # # # |
| # # # # # # # # # # # # # # # # |
2000 + # # # # # # # # # # # # # # # # +
| # # # # # # # # # # # # # # # # # # |
| # # # # # # # # # # # # # # # # # # |
| # # # # # # # # # # # # # # # # # # |
| # # # # # # # # # # # # # # # # # # # # |
| # # # # # # # # # # # # # # # # # # # # |
0 + # # # # # # # # # # # # # # # # # # # # +
+--+---------------------+---------------------+----------------------+---------------------+---------------------+--+
0 0.2 0.4 0.6 0.8 1 </pre>
=={{header|REXX}}==
If a vertical histograph &nbsp; (instead of a &nbsp; <big><big><big>&lt;</big></big></big> &nbsp; shaped horizontal histograph) &nbsp; were to be used, &nbsp; it would be a &nbsp; <big><big>V</big></big> &nbsp; shaped.
331

edits