rstellian

45 Reputation

4 Badges

8 years, 59 days

MaplePrimes Activity


These are questions asked by rstellian

Hi everyone,

In the RandomTools package, the Generate(integer(range = A..B)) function generates a random integer in the range A..B. All integers in that range have the same probability to be generated, that is, 1/nops([seq(A..B)]). However, I would like to specify the probabilities of each integer. How to do so?

Example: range = 1..5. Instead of P(X=j)=1/5 with j =1,2,3,4,5, let's say the probabilities should be as follows:

P(X=1) = 0.2, P(X=2) = 0.5, P(X=3) = P(X=4) = P(X=5) = 0.1

How to generate a random integer between 1 and 5 with these probabilities?

Thank you in advance.

Hi everyone,

I was wondering how I could modify the thickness of edges in a graph displayed as a Maple plot through DrawGraph. The point is, the graph comprises 100 vertices and 1000 edges. By default, edge thickness is set as 2 but due to the high number of edges I would like to set edge thickness to1 or even 0. How can I do so?

Here is an example with a random graph:

with(GraphTheory) : with(RandomGraphs) : G := RandomGraph(100, 1000) : DrawGraph(G)

 

Thank you very much

Hi everyone,

I'm looking for some way to simplify the following procedure:

 

scm := proc(X, x) global xx;

if 1 <= X and X < 10 then xx := cat(x)

elif 10 <= X and X < 100 then if 1 <= x and x < 10 then xx := cat(0, x) else xx := cat(x) end if

elif 100 <= X and X < 1000 then if 1 <= x and x < 10 then xx := cat(0, 0, x) elif 10 <= x and x < 100 then xx := cat(0, x) else xx := cat(x) end if

elif 1000 <= X and X < 10000 then if 1 <= x and x < 10 then xx := cat(0, 0, 0, x) elif 10 <= x and x < 100 then xx := cat(0, 0, x) elif 100 <= x and x < 1000 then xx := cat(0, x) else xx := cat(x) end if

elif 10000 <= X and X < 100000 then if 1 <= x and x < 10 then xx := cat(0, 0, 0, 0, x) elif 10 <= x and x < 100 then xx := cat(0, 0, 0, x) elif 100 <= x and x < 1000 then xx := cat(0, 0, x) elif 1000 <= x and x < 10000 then xx := cat(0, x) else xx := cat(x) end if

end if

end proc

 

Any tips? Thank you in advance.

Hi everyone, 

I seek for creating a discrete random variable with the following characteristics. Let i be an integer between 1 and 100. The random variable is an integer, among i-x, i-x+1, i-x+2..., i-1, i+1, i+2... i+x. For example, with i=20 and x=5, the random variable is an integer between 15 and 25; with i=23 (and again x=5), the random variable is an integer between 18 and 28; and with i=98, the random variable is an integer among 93, 94... 97 and then 99, 100, 1, 2, 3.

Each possible value has the same probability, that is, 1/2x.

Any tips? Thank you in advance.

Hi everyone,

Instead of writing:

a[1] < b[1] or (a[1] = b[1] and a[2] < b[2]) or (a[1] = b[1] and a[2] = b[2] and a[3] < b[3]) or (a[1] = b[1] and a[2] = b[2] and a[3] = b[3] and a[4] < b[4]) or (a[1] = b[1] and a[2] = b[2] and a[3] = b[3] and a[4] = b[4] and a[5] < b[5])...

Is there a more convenient way to do so? Plus, what if a[1] = b[1] and a[2] = b[2] and ... and a[99] = b[99] and a[100] < b[100]? I do not imagine writhing everything.

Thanks for your help. 

1 2 Page 1 of 2