The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sparse Indexing: Large Scale, Inline Deduplication Using Sampling and Locality iBot UNIX and Linux RSS News 0 06-08-2009 11:30 PM
Sampling and Binning- Engineering problem Needhelp2 Shell Programming and Scripting 7 09-05-2008 03:11 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-29-2009
Dedalus Dedalus is offline
Registered User
  
 

Join Date: May 2009
Location: Italy/France
Posts: 60
Uniform sampling

Hi

My goal is to build a C function that perform a uniform sampling. I mean that I have a big file with a lot of data and I'd like to take just some data samples accordly the uniform distribution.

Es.
file1: a b c d e f g h i l m n o p q

An example would be to flip a coin for each letter and select all letters
for which the coin showed the head.

I have used the srand() system call, but it is not uniform.
Can anyone suggest a way to start?
Thanks

D


---------- Post updated at 08:00 PM ---------- Previous update was at 06:30 PM ----------

Hi i'm trying in this way:

Code:
......
#define RAND_MAX 2
 srand(time(NULL));
 ....... in the loop

p=rand()%RAND_MAX
and if the index is greater than 0 grab the letter otherwise leave it.
If you have a different suggestion let me know

thanks
D.
  #2 (permalink)  
Old 06-29-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,788
Depending on what you need, the srand()/rand() PRNG combination works well. But for a larger number of samples, it starts being predictable and clusters. More advanced generators are the Blum-Blum-Shub generator or Fortuna. If you need real random numbers, you might try a service like random.org or build your own true random number generator.
  #3 (permalink)  
Old 06-29-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
FWIW -

in terms of statistical sampling practices if you need a mean and standard deviation what you are doing is really overkill, and results in a sample size of 50% of the data.
You might just as well mean/std deviation/ANOVA or whatever the whole file.

For example, a statically signficant (95% confidence) sample size for the population of the US used in polling: ~1526 persons taken out of 300 million using systematic sampling methods. What you are doing is sort of systematic sampling, yes, but the intent of sampling is not to look at almost everything.
  #4 (permalink)  
Old 07-06-2009
Dedalus Dedalus is offline
Registered User
  
 

Join Date: May 2009
Location: Italy/France
Posts: 60
ok
I'll check more in deep for differents solutions

Thanks

D.
Sponsored Links
Reply

Bookmarks

Tags
sampling, uniform

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:18 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0