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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:57:47+00:00 2026-06-15T12:57:47+00:00

I am looking for a simple algorithm how to generate pseudo-random floating point numbers

  • 0

I am looking for a simple algorithm how to generate pseudo-random floating point numbers using only ANSI rand() function but with arbitrary probability distribution. For a simple uniform distribution I use following code:

x = (float)rand() / (float)RAND_MAX;

Of course it is not very accurate, but enough for my needs. I need also other distributions like logistic and gaussian. Ideally I have to define an arbitrary pdf using a simple vector of finite length, e.g. for logistic pdf this vector may look like:

logistic_pdf = {0., 0.26894, 0.33924, 0.41742, 0.5, 0.58257, 0.66075, 1.};

and for uniform (using same dimensionality 8):

uniform_pdf = {0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125};

This is only an idea. But I am not sure how to implement it efficiently using rand()->{0...RAND_MAX} only.

  • 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-15T12:57:49+00:00Added an answer on June 15, 2026 at 12:57 pm

    there is no simple algorithm to do arbitrary complex things. you have to find the inverse probability integral transform for each of your ‘arbirary’ distributions.

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

Sidebar

Related Questions

I've been looking for a simple Java algorithm to generate a pseudo-random alpha-numeric string.
I am looking for a simple but efficient Objective-C algorithm which, starting from a
I want to generate positive random semi-definite matrices. I am looking for an algorithm
I have a relatively simple algorithm that walks an std::vector looking for two neighbouring
As part of an attempt to generate a very simple looking sky, I've created
Ok, this is an embarassingly simple-looking problem, but is driving me crazy. I'm learning
I'm looking for a simple shearing algorithm. The image to be sheared is binary
I'm looking for a very simple algorithm for computing the polygon intersection/clipping. That is,
I am using this simple algorithm for searching some text in document and taging
Is there a simple algorithm to encrypt integers? That is, a function E(i,k) that

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.