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 8269299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:10:52+00:00 2026-06-08T06:10:52+00:00

This is not homework. I would like to generate a random integer sequence (50

  • 0

This is not homework. I would like to generate a random integer sequence (50 digits between 0:9) from /dev/random in R. I have a hardware entropy key.

I have found two “ideas”, neither of which I can get to supply me with the numbers I am after:

1) RDieHarder. Seems to allow access to /dev/random, but I cannot get it to produce the integer sequence that I require. e.g.

>library(RDieHarder)  
>x  <-dieharder(rng="/dev/urandom", psample=50) #urandom used for example

2) The accuracy package can supply true random numbers, but appears to be out of date and I can’t see how to just sequence from /dev/random. e.g.

>library(accuracy)
>x=runifT(50)

Yes I have read Knuth etc and understand the problems of TRNGs (hence the hardware entropy key).

Any other ideas? Thanks.

  • 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-08T06:10:54+00:00Added an answer on June 8, 2026 at 6:10 am

    Here’s how to read from a dev and get n numbers from a to b inclusive:

    readRandom <- function(n,a,b,dev="/dev/urandom"){
      size = b-a + 1
      rng = file(dev,"rb") # open connection
      nums = readBin(rng,what="integer",n=n) # read some 8-byte integers 
      close(rng) # close the connection
      return( a + nums %% size ) # reduce range and shift
    }
    

    If I read from /dev/random it blocks since my system runs out of entropy, but your key should be busy feeding entropy into the system, I think….

    The ‘edge’ effect problem is as follows. Suppose I generate random integers from 0 to 10, but you want integers from 0 to 6. Then X %% 7 would generate twice as many 0,1,2,3 values, because the mapping is this:

    > (0:10) %% 7
     [1] 0 1 2 3 4 5 6 0 1 2 3
    

    Now readBin is getting 8-bit integers, which are huge, so the odd few extra numbers at the end of the sequence shouldn’t make much difference…

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

Sidebar

Related Questions

Right off the bat - no, this is NOT homework. I would like to
I would like to ask some help. This is not homework but it is
Sounds like a homework? no it's not. I worked up the logic for this
First of all, this is not homework! :) Say I have an NSString: the?or?
This is not a homework. Visually it looks like a tree, but all leafs
This is not homework . I am interested in setting up a simulation of
This is not homework, I need this for my program :) I ask this
Please note that this is not homework and i did search before starting this
To clarify before I begin, this is NOT homework but rather I am studying
This is not exactly homework but it is related to my studies: A grammar

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.