Question: Trouble getting the Sample(X, out) command to output the data used to sample the distribution X. I am specifying the rtable correctly?

out_parameter_for_Sample(_)_and_rtables.mw
When I generate sample data using a random variable, a normal distribution and the Sample command, I want to see the sample and the values used to randomly evaluate the distribution which generates said sample. The Maple help sheets say you can so this with the out parameter in the Sample command. I try several different calls and hoped the rtable is filled on execution. As seen below, the execution fails. Am a specifying the rtable incorrectly? See attached Maple sheet.

restart

NULL

NULL

with(Statistics)

with(LinearAlgebra)

NULL

When I generate sample data using a random variable, a normal distribution and the Sample commands, I want to see the sample and the values used to randomly evaluate the distribution. The Maple help sheets say you can so this with the out parameter in the Sample command.

NULL

NULL

NULL

From the help, we are required to specify a float rtable, that will be filled when the Sample command is succesfully executed.

NULL

Define a random variable.

X := RandomVariable(Normal(0, 1))

_R

(1)

Sample that random variable. We sample it 10 times and look at the output.

A := Sample(X, 10)

Vector[row](%id = 36893491057099280004)

(2)

The float rtable is defined with the sample number of elements as will be sampled.

tab1 := rtable(1 .. 10, datatype = float)

Array(%id = 36893491057099270012)

(3)

NULL

tab2 := convert(rtable(1 .. 10, datatype = float), list)

[HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0)]

(4)

Now I try several different calls and hope the rtable is filled on execution.

A := Sample(X, 10, out)

Error, invalid input: no implementation of Statistics:-Sample:-ModuleApply matches the arguments in call, 'Statistics:-Sample:-ModuleApply(X,10,out)'

 

A := Sample(X, 10, out = tab1)

Error, invalid input: no implementation of Statistics:-Sample:-ModuleApply matches the arguments in call, 'Statistics:-Sample:-ModuleApply(X,10,out = tab1)'

 

A := Sample(X, 10, out = tab2)

Error, invalid input: no implementation of Statistics:-Sample:-ModuleApply matches the arguments in call, 'Statistics:-Sample:-ModuleApply(X,10,out = tab2)'

 

A := Sample(X, 10, out = true)

Error, invalid input: no implementation of Statistics:-Sample:-ModuleApply matches the arguments in call, 'Statistics:-Sample:-ModuleApply(X,10,out = true)'

 

NULL

As seen above, the execution fails. Am a specifying the rtable incorrectly?

NULL

NULL

NULL


 

Download out_parameter_for_Sample(_)_and_rtables.mw

 

Please Wait...