Small step random number generator

조회 수: 3 (최근 30일)
Jim
Jim 2014년 4월 28일
편집: Image Analyst 2014년 4월 28일
Hi I need a random number generator which generates a random number between 0 and 1. The generator has to produce values as small as 1e-13. Currently I am using a vector,
vec=0:1e-13:1
where I get random numbers from. This process is very slow and time consuming as you can imagine. Does anyone know a better alternative ?
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 28일
This is not clear, random number between 0 and 1? or small numbers?
dpb
dpb 2014년 4월 28일
Stratified sampling, mayhaps?

댓글을 달려면 로그인하십시오.

답변 (1개)

John D'Errico
John D'Errico 2014년 4월 28일
편집: John D'Errico 2014년 4월 28일
The existing RNG produces numbers that small, and smaller. Admittedly, the probability of getting any such value is small, but that is the nature of a random generator.
Why are you doing something as insane as this? Do you realize that simply generating a vector of that obscene length will take a huge amount of time? Sorry, but your method is completely insane.
For example, consider how many elements the vector 0:1e-13:1 has in it. A simple computation tells us it has 1+1e13 elements. Stored as doubles, each element will require 8 bytes,
8*1e13/2^40
ans =
72.76
so approximately 73 terabytes of RAM. As I said, insane. Read the help for rand.
doc rand
Perhaps you want numbers on a log scale, or something like that. Or maybe you want some variety of discrete RNG, quantized at that level. If so, then be clear about your goals. Even if those are your goals, there are far easier ways to do so.
  댓글 수: 1
Image Analyst
Image Analyst 2014년 4월 28일
편집: Image Analyst 2014년 4월 28일
Jim's "Answer" moved here because it's a comment to John, not an answer to the initial question:
Dear John, I know that my current matlab script is insane, I am currently creating a vector with steps of 1e-9 (can't go any bigger because of a lack of memory). I need these randoms numbers to sample a user defined distribution function. The distribution function I have is normalized so I need to produce random numbers between 0 and 1. The idea is that I fill 3D space with for example ten million random points, all the points that lay beneath my distribution function are taken into account while all the other points are deleted. The distribution function has a exponent with a negative terms so it drops to really low values.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by