Items tagged with random

Hi everybody,

I would like to define a function with random values to be used in pdsolve (numeric) as a initial condition.

Any help?



Dear Community,

How could I specify a list of random colors using some kind of an RGB function, which then could be used in another command for coloring? I think of something like this:

myColors := [ seq( RGB ( [rint(0,255) , rint(0,255) , rint(0,255)] ) , j = 1 .. 20 ) ] :

which does not work of course :-)  This should produce me a list of 20 random colors.  What would be the right RGB color function?

Tx for the kind help in advance

best regards


To gererate a random initail cofigration -1 or 1

spin = (-1).^(round(rand(N)));


for i=1:1000,


neighbours = circshift(spin, [ 0 1]) + ...

circshift(spin, [ 0 -1]) + ...

circshift(spin, [ 1 0]) + ...

circshift(spin, [-1 0]);

how to do this in maple?

if you want a random interger between 0 and 100

what will be the command?

Hi all

Is Ising a package?

for i = 1:12000

%while (1),

% Choose a random value between 0 and 1 for the interaction strength

J = rand()+1e-10;

% Perform a simulation

[M, N, E] = ising2(n_grid, J);

% Records the results

Ms = [Ms M/(n_grid^2)];

Es = [Es E/(n_grid^2)];

Ns = [Ns N];

Js = [Js J];

i = i+1;

of a (concrete/general) triangle, making use of Maple tools in an efficient way?  Mathematica applies the barycentric coordinates and the Dirichlet distribution to this end. More generally, how to efficiently choose a random point in a given bounded region?

Coding in key generation of RSA Cryptosystem

message :=123456;

u := nextprime(RandomTools[Generate](integer(range = 10^100 .. 10^(110-1))));

v := nextprime(RandomTools[Generate](integer(range = 10^100 .. 10^(110-1))));

N := u*v;

phi := (u-1)*(v-1);

In RSA cryptosystem, the encryption or decryption of message only can be existed between range 1<=message<=N. This means that if the value of message bigger than N value then we can't get back the original value when performing decryption.Thus, wanna to ask that how can we create a coding so that the system will recognise the random integer u and v whether lie between range 1<=message<=N, means wanna crete a coding that if  N>=message then it will continue to the phi step whereas if message>=then the system need to regenerate the u and v until it satisfy the condition  1<=message<=N .Thus please help as i am a beginner in Maple.Thanks.

May I know any command can help to random selected a position in a group of bit number then flip that number but with condition after convert to bytes the number cannot be more than 7?

For example,

I have integer 3, i convert to binary become 0000011

then i need a command to random select a position to flip and only one bit can be flipped.

After that the group of flipped number will convert back to decimal, but total value cannot more than 7? any command can solve?  Thank you. 

How to generate a random normal distribution of points around the point [3,15] for example?

Wanna ask that how to make maple program to select a random binary number in base 2.

For example, suppose that we have a value 11101100(8 bit which in base 2),then how to let Maple to select a binary number randomly and the binary bit of the random number always shorter than the previous then sum it together?

For example the program will select 1101101(7-bit) and sum it together(11101100+1101101=101011001,in base 2)

Can somebody help me thanks.

I have use a ''for cycle'' in order to get a series of points. I would like to save those points in a vector in order to use it for the ''PolynomialFit'' comand. The problem is that the points that I save are sort randomly. How can I take the value of the vector A in the right sequence? in the underline string you can plot the walue of A over t (which is not sorted). I can not use the sort command as I used for t even for A because the points are not increasing.

This is my code:


Atot := 0:

for ii from 0 by 0.01 to 2 do

PtotFkt := ii->  ii^2 :

Ptot := PtotFkt(ii):

Atot := Atot+0.01*Ptot:

A[ii] := Atot: #Save points in a Table

t[ii] := ii: #Save point in a table

end do;

AV := convert(A, list): #conversion from table to list
nops(AV);  #number of points

timme := convert(t, list): #conversion from table to list
nops(timme); #number of points


with(Statistics); #PolynomialFit

X := Vector(AV, datatype = float);

Y := Vector(sort(timme), datatype = float);

plot(Y, X, style = point, symbol = asterisk, color = blue);

regress := PolynomialFit(10, X, Y, time);

curve1 := plot(regress, time = 0 .. 2);

Hei, I'm trying to create a random walk in the plane, with constant step length (=1) and the angle between two consecutive steps are decided by a probability density function. I just can't seem to find out how I should implement the density function into my worksheet.

The probability density function is: p(phi)=(1/4)*cos(phi/2), on the interval [-Pi,Pi].
And  I think i managed to do it by selecting a random angle, but don't know how to generate a random angle given this probability function. Any ideas? It'd be highly appreciated!

How to produce such a plot with Maple?
enter image description here

The difficulty is that the geom3d package does not include a command for a cylinder whereas
the plottools package has the cylinder command, but does not have a tool to determine whether
two random cylinders intersect.

Working on a code to create random lines. Here is the code: 

M:=1; N:=1500; R3:=rand(1..3): # M=lines, N=steps

for i from 1 to M do
   for j from 0 to N do
   if j=1 then X[i,1]:=1; Y[i,1]:=0;
    elif j>1 then
        if r=1 then X[i,j]:=2*X[i,j-1]-X[i,j-2]; Y[i,j]:=2*Y[i,j-1]-Y[i,j-2]
        elif r=2 then X[i,j]:=X[i,j-1]+Y[i,j-1]-Y[i,j-2]; Y[i,j]:=Y[i,j-1]-X[i,j-1]+X[i,j-2];
        elif r=3 then X[i,j]:=X[i,j-1]-Y[i,j-1]+Y[i,j-2]; Y[i,j]:=Y[i,j-1]+X[i,j-1]-X[i,j-2];
      end if;
    end if;
  end do:
end do:

Now the code works fine. But I don't want the lines to cross its own path. I want it to stop if R[i,j]=R[i,k] for any 0<k<i-2 for j=0..N. What I have so far is:

for i from 1 to M do
  for j from 1 to 40 do
    for k from 1 to j-2 do
     if R[i,j]=K[i,k] then x:=j; print(b[i]=j); break; end if;
     end do;
   end do;
end do;

Now it works aswell, but it doesn't stop when it hits the crossing point. I want it to stop so i get one b[i]=j per M. So I need it to break two for loops so that it goes through i M times and stops everytime it reaches a crossing point


I'm trying to create a code that allows me to model a random walk for 50 people. I'm using r[i]= {X[i],Y[i]} where i is the number of steps and r[i] the position in the i-th term.

I have created three possibilities:
2r[i]-r[i-1] - go stright forward

{x[i]+y[i]-y[i-1],y[i]-x[i]+x[i-1]} - turn right

{x[i]-y[i]+y[i-1],y[i]+x[i]-x[i-1]} - turn left

The first step I want them to make is to point (1,0) and from there I want them to take 1500 random steps.

M:=50; N:=1500; R3:=rand(1..3):

for i from 1 to M do
for j from 1 to N do
if j=1 then X[i,1]:=1; Y[i,1]:=0;
elif j>1 then
if r=1 then R[i,j]:=2*R[i,j]-[R[i,j-1];
elif r=2 then R[i,j]:=[X[i,j-1]+Y[i,j-1]-Y[i,j-2],Y[i,j-1]-X[i,j-1]+X[i,j-2]];
elif r=3 then R[i,j]:=[X[i,j-1]-Y[i,j-1]+Y[i,j-2],Y[i,j-1]+X[i,j-1]-X[i,j-2]];
end if;
end if;
end do:
end do:


The first and second step works, but from there it seems Maple is having trouble getting the correct digigts, because the formulas coming out are correct.

I have tried putting in different types of X, Y and R reads, but have gotten stuck. If someone could help me spot what this code is missing I would be very gratefull. I think Maple is just missing a way of reading X and Y but i might be wrong.

1 2 3 4 5 6 Page 1 of 6