wu :: forums
« wu :: forums - Random Connections »

Welcome, Guest. Please Login or Register.
May 15th, 2024, 5:04am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Eigenray, Grimbal, towr, SMQ, ThudnBlunder, william wu, Icarus)
   Random Connections
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Random Connections  (Read 2357 times)
Skandh
Junior Member
**





   


Gender: male
Posts: 77
Random Connections  
« on: Aug 18th, 2011, 10:45am »
Quote Quote Modify Modify

I was going through some algorithmic puzzles and got bit confused in following problem (the reason could be I usually get nervous when I see probability  Sad )
 
"Random connections. Write a program that takes as command-line arguments
an integer N and a double value p (between 0 and 1), plots N equally spaced dots of size
.05 on the circumference of a circle, and then, with probability p for each pair of points,
draws a gray line connecting them"
 
Let's say I have N=10 equally spaced dots and p=0.3. Hence with the given data we have 45 pair of points.
 
So we have to draw lines between these 45 pairs with probability 0.3. What does this mean?
IP Logged

I wanna pull by legs!!!
pex
Uberpuzzler
*****





   


Gender: male
Posts: 880
Re: Random Connections  
« Reply #1 on: Aug 18th, 2011, 11:37am »
Quote Quote Modify Modify

on Aug 18th, 2011, 10:45am, Skandh wrote:
So we have to draw lines between these 45 pairs with probability 0.3. What does this mean?

The usual meaning is that each of these 45 lines can be drawn, each independently with a probability of 30%. So, something like
 
for i in 0 to 8
  for j = i+1 to 9
    draw a random number r, uniform in (0,1)
    if r < 0.3
     draw a line from point i to point j
    end if
  end for
end for
IP Logged
TenaliRaman
Uberpuzzler
*****



I am no special. I am only passionately curious.

   


Gender: male
Posts: 1001
Re: Random Connections  
« Reply #2 on: Aug 23rd, 2011, 11:51pm »
Quote Quote Modify Modify

This is the Erdos-Renyi model for generating random graphs [1].
 
-- AI
[1] http://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93R%C3%A9nyi_model
IP Logged

Self discovery comes when a man measures himself against an obstacle - Antoine de Saint Exupery
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board