Items tagged with random random Tagged Items Feed

I am trying to find the pdf of the inverse of a random variable X, that represents a distribution I defined. I currently have : 

with(Statistics):
T:=Distribution(PDF=(x->piecewise(0<x and x<1,1/4,3<x and x<5,3/8,0)));
X:=RandomVariable(T);
PDF(X,u);
CDF(X,u);
Y:=1/X;
T1:=RandomVariable(Y);

but this seems to be incorrect as I get a message saying T1:=RandomVariable(Y) is being passed a wrong argument. 

What is the right way to obtain the pdf of 1/X?

 

In Maple TA in blackboard I am creating an assignment. Each week a part of the assignment will be posted. I was wondering if it is possible to have the same random variables in differnet assignmemts. That way the students can use their prior work. 

So in week one the students will get a set of random variables. But in week two a new assignment is posted were I want the same variables to come up for each student. Is this possible? (all students will have their own unique set of variables)

Hi all,

 

I want to create a (set of) samples from an own distribution. The distribution itself is a normal distribution, but with some 'gaps', as shown below:

plot(exp(-(t-10)^2/(2*(0.5e-1*10)^2))*piecewise(t<9,0,t<9.9,1, t<10.1,0, t<11,1), t = 8.5 .. 11.5)

(It is supposed to represent the distribution of discrete resistor values (e.g. 10 ohms), where not only the values above the tolerance (e.g. 10%) are removed, but also those who can be sold as higher precision resistors (eg. 1%). The mean, lower tolerance and higher tolerance should be variables).

Because of the fact that in order to be able to use the Sample function, the PDF should be twice differentiable, the 'truncation' in the middle is realised using logistic functions.

I am able to create said distribution, and produce a DensityPlot, but when I try to take a (even a single) Sample from a RandomVariable from that distribution, Maple keeps calculating and no sample is produced.

GetDist := (mu, alpha, beta) -> Distribution(PDF = unapply(LotRPDF(t, mu, alpha, beta), t)):
T := GetDist(10, .1, 0.1e-1);
DensityPlot(T);
RandomR := RandomVariable(T):
Sample(RandomR, 1);

Where LotRPDF is the function depicted above, mu is the mean (10), alpha is the maximum tolerance (10%), , beta is the minimum tolerance (1%)

Am i overlooking something simple? Or is there a more fundamental error in my approach? I've added the maple sheet with more details.

RandomVariableSample.mw

 

Hi there, this is my first post in this forum. I hope you can help me with my problem :)

I've created a little program to solve a problem for my class. This is the first time, I wrote a program with Maple, so please don't laugh. 

I've posted the Maple code below:

 

restart; randomize():
with(plots): with(plottools): with(LinearAlgebra): with(Statistics): with(MTM):

s:={1=2, 3=2}:

 

Realisierung:=proc(np,volfrac)

local m, h, adresses, rndmAdrs, omega: omega:=Vector[row](np,s);

adresses:=Vector(np-nops(s));

h:=1;
for m from 1 to np do
if(omega[m]=0) then
adresses[h]:=m;
h:=h+1;
end if
od;

randomize():
rndmAdrs:=Shuffle(adresses);

for m from 1 to volfrac*np do
omega[rndmAdrs[m]]:=1
od:

for m from 1 to np -(volfrac*np+nops(s)) do
omega[rndmAdrs[m+int8(volfrac*np)]]:=2
od:

omega;

end:

 


RealMatrix:=proc(np,nr,volfrac)

local m, alle:

alle:=Matrix(nr,np); for m from 1 to nr do

randomize();

alle[m]:=Realisierung(np,volfrac); od;

alle;

end:

RealMatrix(5,5,0.4);

 

I used the Shuffle function from Statistics-package to randomly permutate the components in the Vector adresses. Which works fine. By setting Randomize(); I get randomly results vor this permutation, when I execute the whole worksheet.

But when the "Realisierung" procedure is called in the for loop of the "RealMatrix" procedure, always the same Permutation is calculated.

This leads to the fact, that every row in my matrix looks the same.
Like in the example

2 1 2 2 1
2 1 2 2 1
2 1 2 2 1
2 1 2 2 1
2 1 2 2 1

but the lines should be randmly like

2 1 2 2 1
2 2 2 1 1
2 1 2 1 2
2 1 2 2 1
.....

 

Obvioulsy the problem is in the randomize()-command. I tried to place it directly after "restart" and directly before the Shuffling is executed.
But I had no succes. 

Maybe one of you can help me?
Would be great!
Thanks

 

 

 

 

 

 

Dear all;

nice to speak with you.

complete a table randomly by positive three-digit numbers and display only the symmetrical numbers.

 

Thanks

Hello,

I am trying to make c (0.001<=c<=0.02) a random value at each time step.But with my code c is choosing randomly from the interval then solveing the equation for fixed c at each time step.

How can I mack c a diffrent random value at each time step?

This is my code:

> with(DEtools); with(plots);
>
> Ra := RandomTools:-Generate(distribution(Uniform(0.001, 0.02))); c := Ra;
> f := .1;
>
> eq := diff(X(t), t) = 1-f-c*X(t);
>
> init := X(0) = 100;
>
> sol := dsolve({eq, init}, {X(t)}, range = 0 .. 100, numeric);
>
> odeplot(sol, [[t, X(t)]], t = 0 .. 100);

 

Thank you

M:=Array([[a+2*b,b],[x1+y1,z1+z2]]);
pars:=indets(M);
npars:=numelems(pars);

myRand:=RandomTools[Generate](float(range=-3..3),makeproc=true):

set1:={seq(pars[i]=myRand(),i=1..npars)};
numM:=subs(set1,M);
LinearAlgebra:-Rank(numM);

is there a way to make sure that the random values generated from myRand(), subs into M, to make sure that each cell of M is between 0 and 1?

Basically, what I need is being able to simulate some values, subject to each cell of M is between 0 and 1, and find the rank of M. I want to do that efficiently 20 times (or more possibly). Those values that make the cells out of 0 and 1 do not count as 1 of the 20 simulations.

 

Thanks,

 

casper

 

 

Hello everybody,

 

I find a answer on that subject at this link: http://www.mapleprimes.com/maplesoftblog/95508-Monte-Carlo-Pi

But for starting easy, I try this:

with(RandomTools[MersenneTwister]);
directpi := proc (n)
local i, x, y, N;
N := 0;
Digits := 2;
for i to n do
x := GenerateFloat();
y := GenerateFloat();
if x^2+y^2 < 1 then
N := N+1:
end if:
end do:
N;
end proc;


evalf(directpi(4000)/(1000.0), 4);

                             3.176

I would like to know if this code is appropriate and if it is possible to have a random number between -1 to 1 so it will be easier to plot the points in the square with the circle inside.

 

Thank you.

--------------------------------------
Mario Lemelin
Maple 18 Ubuntu 13.10 - 64 bits
Maple 18 Win 7 - 64 bits messagerie : mario.lemelin@cgocable.ca téléphone :  (819) 376-0987

RandomCompositions:= proc(n::posint, k::posint)
local
C,
Compositions:= [seq(C-~1, C= combinat:-composition(n+k, k))],
Rand:= rand(1..nops(Compositions))
;
()-> Compositions[Rand()]
end proc:

R:= RandomCompositions(9,6):
n:= 2^13:
S:= 'R()' $ n:

 

I want to compile statistics each number in a sequence cannot  occur  over twice.

The sequences that do not fit the rule above must be ommitted.

The statistic is  Fermi-Dirac statistics.

confused the Bose-Einstein condensation and Fermi-Dirac statistics.

But the theory is right.

RandomCompositions:= proc(n::posint, k::posint)
local
C,
Compositions:= [seq(C-~1, C= combinat:-composition(n+k, k))],
Rand:= rand(1..nops(Compositions))
;
()-> Compositions[Rand()]
end proc:

R:= RandomCompositions(9,6):
n:= 10:
S:= 'R()' $ n;

S := [4, 1, 1, 1, 2, 0], [3, 2, 1, 1, 0, 2], [0, 1, 1, 0, 0, 7], [0, 1, 1, 5, 0, 2], [1, 0, 3, 1, 3, 1],

        [1, 3, 1, 1, 0, 3], [1, 4, 2, 0, 2, 0], [5, 0, 0, 3, 1, 0], [1, 1, 1, 4, 0, 2], [0, 1, 2, 1, 0, 5]

 

[4, 1, 1, 1, 2, 0] , [1, 1, 1, 4, 0, 2]  and [0, 1, 1, 5, 0, 2] , [0, 1, 2, 1, 0, 5]  are same number 

  but different order.

There are two same sequence. I want to  count  as one, and compile statistics the summation, and 

divide by 8.

the result

0=14/8

1=17/8

2=6/8

...

4=2/8

5=2/8

...

 

RandomCompositions:= module()
local
Compositions, Rand,

RandomCompositions:= module()
local
Compositions, Rand,
ModuleApply:= proc(n::posint, k::posint)
local C;
Compositions:= [seq(C-~1, C= combinat:-composition(n+k, k))];
Rand:= rand(1..nops(Compositions));
()-> Compositions[Rand()]
end proc;

end module:
R:= RandomCompositions(8,6):
seq(R(),i=1..10);

[0, 0, 2, 6, 0, 0], [1, 0, 0, 3, 4, 0], [0, 3, 3, 2, 0, 0],[1, 2, 4, 0, 1, 0], [0, 4, 0, 1, 3, 0],

[2, 0, 1, 4, 1, 0],[2, 0, 1, 1, 3, 1], [1, 0, 4, 2, 1, 0], [1, 3, 0, 2, 0, 2],[2, 0, 3, 2, 1, 0]

with(Statistics):
Tally(R());
[0 = 1, 1 = 4, 4 = 1]

I want to count the 0 to 8 respectively summation,and divide by i.

 But the  seq command  R() isn't conform  with Tally command R() .

Thanks.

 

a:=rand(0..8):
b:=rand(0..8):
c:=rand(0..8):
d:=rand(0..8):
e:=rand(0..8):
f:=rand(0..8):
a()+b()+c()+d()+e()+f()=8;

This is my  programming code.

I want ot set six random summation is  8. 

But the random summation can't reach 8.

It says at

http://www.maplesoft.com/products/maple/new_features/maple18/Language_Programming.aspx#random

"When generating matrices and vectors of floats and integers, these flavors are very fast. "

But when I compare the new

time[real](Generate(('Matrix')(float, 300, 300)))

and

time[real](RandomMatrix(300, 300))

I find RandomMatrix over 300 times faster. Am I doing something wrong, or is RandomMatrix still the fastest way to generate random numbers?

 

 

I want to generate random numbers following the normal distribution within a fixed interval.

 

For example, I want generate 10 random numbers in the interval [2903.5-5, 2903.5+5]. These random numbers should follow the normal distribution with mean 2903.5 and  standard deviation \sigma=3.

 

How can I do this?

 

Thanks.

My problem is i am working with a very large randomly generated output, generated using maple's builtin in random generating functions. I have the output which i want to investigate but i want to be able to reproduce this result when i save and close the worksheet. Since the list of generators is very long copy pasting is not very nice and i donot know the seed of these generaters. I want to ask if i can store the values in variable in the worksheet so that when i open the worksheet i can get the same random generates stored in the variable.

1 2 3 4 5 Page 1 of 5