Items tagged with randomrandom Tagged Items Feed

array randomly...

January 22 2015
1 5

Dear all;

nice to speak with you.

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

Thanks

random value at each time step...

January 09 2015
2 5

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

Generating random variables subject to conditions...

November 02 2014
0 1

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

Simple code for MonteCarlo approximation of Pi...

October 11 2014
1 5

Hello everybody,

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 bitsMaple 18 Win 7 -  64 bits
messagerie : mario.lemelin@cgocable.ca
téléphone :  (819) 376-0987

How to compile statistics each number in a sequenc...

August 23 2014
1 16

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. How to count the same random sequence as one... August 21 2014 0 6 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

...

how to count the number summation ...

August 15 2014
1 10

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.

how to set random summation...

August 06 2014
1 5

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.

Fast random generation...

July 15 2014
2 2

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?

how to generate random numbers with normal distrib...

June 12 2014
2 4

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.

How to save values stored in the variables in a wo...

June 01 2014
0 2

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.

Is there a function to generate random numbers wit...

May 13 2014
0 15

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,

How do I generate a random matrix of this form?...

May 11 2014
2 3

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?

February 19 2014
1 4

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!

obtaining c.d.f from probability mass function...

December 28 2013
2 1

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

 1 2 3 4 5 Page 1 of 5
﻿