I recognize the problems with global data.
And my code could certainly be improved.
However, I also note that the random numbers (ignoring
transformations), need to be constant, while computing the rate.
Otherwise, my algorithm wouldn't work well.
As it is, rounding operations can cause "jumps".
> Abby Spurdle
> on Thu, 28 Jan 2021 08:48:06 +1300 writes:
> I note that there's a possibility of floating point errors.
> If all values have one digit after the decimal point, you could replace:
> qexp (p, rate) with round (qexp (p, rate), 1).
> However, sometimes u
Thanks again for your help,
One digit after the decimal point is enough for my purposes; so, I can
round the qexp function, even if possible errors in floating points are not
a problem.
Thank you very very much,
Denis
Il giorno mer 27 gen 2021 alle ore 20:48 Abby Spurdle
ha scritto:
> I note
I note that there's a possibility of floating point errors.
If all values have one digit after the decimal point, you could replace:
qexp (p, rate) with round (qexp (p, rate), 1).
However, sometimes uniroot will fail, due to problems with input.
On Thu, Jan 28, 2021 at 5:02 AM Denis Francisci
wr
Wonderful!
This is exactly what I need!
Thank you very much!!
Denis
Il giorno mer 27 gen 2021 alle ore 10:58 Abby Spurdle
ha scritto:
> u <- runif (410)
> u <- (u - min (u) ) / diff (range (u) )
>
> constrained.sample <- function (rate)
> { plim <- pexp (c (9.6, 11.6), rate)
> p <- plim
u <- runif (410)
u <- (u - min (u) ) / diff (range (u) )
constrained.sample <- function (rate)
{ plim <- pexp (c (9.6, 11.6), rate)
p <- plim [1] + diff (plim) * u
qexp (p, rate)
}
diff.sum <- function (rate)
sum (constrained.sample (rate) ) - 4200
rate <- uniroot (diff.sum, c (1,
Am Wed, 27 Jan 2021 09:03:15 +0100
schrieb Denis Francisci :
> Hi,
> I would like to generate random numbers in R with some constraints:
> - my vector of numbers must contain 410 values;
> - min value must be 9.6 and max value must be 11.6;
> - sum of vector's values must be 4200.
> Is there a way
Hi,
I would like to generate random numbers in R with some constraints:
- my vector of numbers must contain 410 values;
- min value must be 9.6 and max value must be 11.6;
- sum of vector's values must be 4200.
Is there a way to do this in R?
And is it possible to generate this series in such a way
On Sun, Feb 19, 2012 at 08:39:13PM -0800, Ryan Murphy wrote:
> Hello,
>
> Is there a way to create random numbers that fit a certain specified
> requirement other than distributional characteristics.
> In particular, I would like to create simulated income distributions with
> certain gini coeffic
Hello,
Is there a way to create random numbers that fit a certain specified
requirement other than distributional characteristics.
In particular, I would like to create simulated income distributions with
certain gini coefficient
Ryan
--
Ryan Murphy
2012
B.A. Economics and Mathematics
On 29/04/2010 5:40 AM, Nick Crosbie wrote:
Hi,
In S+/R, is there an easy way to generate random numbers with a
probability distribution specified by an exact user-defined function?
For example, I have a function:
f(x) = 1/(365 * x), which should be fitted for values of x between 1 and
100,000
At 05:40 AM 4/29/2010, Nick Crosbie wrote:
Hi,
In S+/R, is there an easy way to generate random numbers with a
probability distribution specified by an exact user-defined function?
For example, I have a function:
f(x) = 1/(365 * x), which should be fitted for values of x between 1 and
100,000
Hi,
In S+/R, is there an easy way to generate random numbers with a
probability distribution specified by an exact user-defined function?
For example, I have a function:
f(x) = 1/(365 * x), which should be fitted for values of x between 1 and
100,000
How do I generate random numbers with a prob
On 15-Dec-09 13:35:36, Jorge Ivan Velez wrote:
> Dear Maithili,
> Here are two suggestions:
>
># data set
> x <- read.table(textConnection("Name no_of_instances
> AAA 12
> AA17
> A 0
> BBB 11
> BB 6
> B 0
> C 8
> D 3"), header = TRUE)
> closeAllConnections()
> x
>
Dear Maithili,
Here are two suggestions:
# data set
x <- read.table(textConnection("Name no_of_instances
AAA 12
AA17
A 0
BBB 11
BB 6
B 0
C 8
D 3"), header = TRUE)
closeAllConnections()
x
# option 1
do.call(c,with(x, tapply(no_of_instances, Name, runif)))
# option
Dear R helpers
I have following table
Name no_of_instances
AAA 12
AA 17
A 0
On 11/13/2009 11:41 AM, Thomas Unternaehrer wrote:
I need some random numbers in my C program. Here a small example:
#include
void rand (int* n)
{
int len = *n;
for (int i = 0; i < len; i++)
Rprintf("%1.5f
Ups... I've overlooked that part. Thanks a lot for the fast response!
On Fri, Nov 13, 2009 at 6:05 PM, Duncan Murdoch wrote:
> On 11/13/2009 11:41 AM, Thomas Unternaehrer wrote:
>
>> I need some random numbers in my C program. Here a small example:
>>
>>
>> //
I need some random numbers in my C program. Here a small example:
#include
void rand (int* n)
{
int len = *n;
for (int i = 0; i < len; i++)
Rprintf("%1.5f ", unif_rand());
}
dyn.load("rand.dll")
.C("rand",
On 22/10/2009, at 8:25 AM, carol white wrote:
Hi,
To generate random numbers between 0 and 1, do you use rnorm
followed by dnrom? for ex, for 10 variables
a = rnorm(10)
a
[1] -0.87640764 -0.95842391 -1.33434559 -0.63844932 -1.69829393
0.80010865
[7] -0.01026882 -0.23887516 2.2991260
On Wed, Oct 21, 2009 at 8:37 PM, Gábor Csárdi wrote:
> I would suggest to use the generator at
> http://submoon.freeshell.org/pix/valium/dilbert_rng.jpg
> and subtract 8.5.
You may laugh (indeed I did) but some medical trials have used (and
poss still do) telephone-a-human random numbers. When d
I would suggest to use the generator at
http://submoon.freeshell.org/pix/valium/dilbert_rng.jpg
and subtract 8.5.
Best,
Gabor
On Wed, Oct 21, 2009 at 9:25 PM, carol white wrote:
> Hi,
> To generate random numbers between 0 and 1, do you use rnorm followed by
> dnrom? for ex, for 10 variables
>
Uniformly distributed random numbers between 0 and 1? Try ?runif
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of carol white
> Sent: Wednesday, October 21, 2009 2:26 PM
> To: r-h...@stat.math.ethz.ch
> S
Hi,
To generate random numbers between 0 and 1, do you use rnorm followed by dnrom?
for ex, for 10 variables
a = rnorm(10)
> a
[1] -0.87640764 -0.95842391 -1.33434559 -0.63844932 -1.69829393 0.80010865
[7] -0.01026882 -0.23887516 2.29912600 -1.38352143
> dnorm(a)
[1] 0.27171985 0.25202507 0.
Dear, R help
How can I generate random numbers of the multivariate power exponential
distribution.
Regards,
Jeremias Leão.
[[elided Yahoo spam]]
[[alternative HTML version deleted]]
_
25 matches
Mail list logo