Items tagged with random random Tagged Items Feed

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.

Hello guys,

 

I think that the title explains the question very well. Is there any function in MAPLE that allows me to generate N random numbers considering a mean value, standard deviation and a percentile?

 

Thank you,

I want to generate a random matrix of size m x n as follows: for each i between 1 and m, take a random p_i number according to some fixed distribution (for example, uniform distribution in [0,10]). These numbers p_i are independent. Then I'll form a random matrix whose (i,j)-entry is chosen according to a probability distribution that depends on the parameter p_i (for example, it could be Poisson(p_i)). So entries in the same row are independent.

How can I do that?

Loading random number ...

February 19 2014 smith_alpha 40

Hi, 

 

  I tried to use generated random as following

*** 

for j from 1 to 5 do
    c:=rand(0..1):
    d:=c();
    print(`random number`,c(),d);

    if c()=1 then

       print(`Y`)
    else
     print(`N`);
    end if;
  end do:

***

 

  The output is

 

****

                      random number, 1, 0

                               Y

                      random number, 1, 1

                               Y

                      random number, 1, 1

                               N

                      random number, 1, 1

                               N

                      random number, 0, 0

                               N

****

  Why the output numbers in one line are different? And Using "if" sentence seems do not correspond to the printed "c()" value..

 

Thank you very much in advance!

 

How to calculate c.d.f from probability mass function. Suppose that the pmf of a discrete random variable is given : f(x)=(2*x+1)/25, x=0,1,2,3,4

I have a set of 19 different items I need randomize, lets call them A-S. I tried the Random command, Random(19,A-S) listing all of the possiblities. I want each letter to be used once in that 19 times and using this way does not do that. Is there another command I can use to achieve this?

Suppose I broadcast a game show where every episode there is 5 randomly chosen topics from 8 possible topics (A,B,C….). how can I get maple to do this automatically?

 I thought I could use

  > with(combinat):

> choose([A,B,C,D,E,F,G,H], 5);

of course the output comes out ordered. is there some way to randomize it? or another way? rgds

If I put in the randomize(#) command with the same actual number each time before generating a sequence of random numbers,  I would expect to get the same sequence of results from repeated use of  

round( Generate(distribution(DiscreteUniform(5,10))) )

each time. Actually, I get completely different sequences of numbers.

This also happens with the alternative method of SetState in RandomTools

This is not only annoying...

1 2 3 4 5 Page 1 of 5