Hello Piddlers,
I am moving from R to PDL, with tons of experience with Perl, lots with R
but zero with PDL,
so this is a pretty basic question. I can see from the PDL Book that PDL is
very
sophisticated, with much more functionality than I will ever use, but I want
to master basic PDL to leverage my Perl. My focus is on probability in two
dimensions so
I will be working mostly with 1-dimensional vectors. Here is an example
from R that
I would like to learn how to do in PDL. It is a small example but once I
master
the construction of this data I will extend it to much larger vectors.

Suppose I have random variable X whose values and probabilities are as
follows:
*x* *p(x)*
0 1/8
1 3/8
2 3/8
3 1/8
To get a sample of 50 random values drawn from this population with
replacement in R I
would say:
x <- seq.int(0,3) # Concatenate a sequence of ints from 0 to 3.
x # print x.
[1] 0 1 2 3
weights <- c(1/8, 3/8, 3/8, 1/8) # Another form of concatenation.
weights
[1] 0.125 0.375 0.375 0.125
s <- sample(x, 50, replace=TRUE, prob=weights)
s
[1] 0 1 1 3 2 2 2 3 2 0 0 1 3 1 1 3 0 2 1 2 2 1 3 1 2 2 0 2 2 2 3 2
[33] 1 1 3 1 2 2 1 1 0 1 3 2 2 1 3 0 1 1
I can now manipulate *s*, calculate its statistical properties and graph
its probability distribution. Fifty integer values is not very interesting
but the problems I am studying have thousands of values and very different
weights. How do I do this in PDL? I have PDL::Stats::Basic and
PDL::Stats::Distr installed along with PGPLOT but it's generating this
basic data that has me stumped.
Thanks and regards,
Will Schmidt
t.william.schm...@gmail.com

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
pdl-general mailing list
pdl-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-general