Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9254559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:30:03+00:00 2026-06-18T11:30:03+00:00

I am asked: Using your raspberry pi, write a python script that determines the

  • 0

I am asked:

Using your raspberry pi, write a python script that determines the randomness
of /dev/random and /dev/urandom. Read bytes and histogram the results.
Plot in matplotlib. For your answer include the python script.

I am currently lost on the phrasing “determines the randomness.”

I can read from urandom and random with:

#rb - reading as binary
devrndm = open("/dev/random", 'rb')
#read to a file instead of mem?
rndmdata = devrndm.read(25) #read 25bytes

or

with open("/dev/random", 'rb') as f:
    print repr(f.read(10))

I think the purpose of this exercise was to find out that urandom is faster and has a larger pool than random. However if I try to read anything over ~15 the time to read seems to increase exponentially.

So I am lost right now on how to compare ‘randomness’. If I read both urandom and random in to respective files how could I compare them?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:30:05+00:00Added an answer on June 18, 2026 at 11:30 am

    Could it be as simple as:

    In [664]: f = open("/dev/random", "rb")
    In [665]: len(set(f.read(256)))
    Out[665]: 169
    
    
    In [666]: ff = open("/dev/urandom", "rb")
    In [667]: len(set(ff.read(256)))
    Out[667]: 167
    
    
    In [669]: len(set(f.read(512)))
    Out[669]: 218
    
    In [670]: len(set(ff.read(512)))
    Out[670]: 224
    

    ie. asking for 256 bytes doesn’t give back 256 unique values. So you could plot increasing sample sizes against the unique count until it reaches the 256 saturation point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am asked this: Using your RPi, write a C function that reads the
I have been asked to write a program using python for an assignment. I
Earlier I asked this question ( and after some googling I read Using your
So, as per a separate question that I asked I'm using the following code
I was asked to write a swap without using temp variables or using xor
This was A Question Asked by my teacher. How Would You Stop Your Script
I am being asked to create a table using javascript that displays simple arithmetic
I've been asked about using the Qt database interface for Oracle. What's a good
Yesterday I asked about using an exlusive maven repository, now it turns I need
Referring to the other question I asked Django using AJAX with Forms, Views ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.