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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:38:15+00:00 2026-06-07T17:38:15+00:00

I am using normal(mean, sigma) to generate random number for normal distribution with mean

  • 0

I am using normal(mean, sigma) to generate random number for normal distribution with mean and sigma. My sigma is 8db and mean is 0. But I always get negative value when I do normal(mean, sigma). Is there any way I can get positive number for this?

  • 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-07T17:38:17+00:00Added an answer on June 7, 2026 at 5:38 pm

    You do not simply call normal(double mean, double sigma).
    Instead, call double r8_normal ( double a, double b, int &seed ), where a is the mean, b is the sigma, and seed initializes the random number generator.

    I was able to compile and use the Normal library in the link you provided.
    I downloaded normal.cpp and normal.hpp. These are old files, mostly translations from Fortran.
    I had to modify normal.hpp by adding #include <complex> and changing complex to std::complex in the first two declarations to get it to compile for me at low warning levels.

    Then I created a test driver:

    #include "normal.hpp"
    #include <iostream>
    
    int main() {
        int seed = 123;
        std::cout << r8_normal (0.0, 8.0, seed) << '\n'
                  << r8_normal (0.0, 8.0, seed) << '\n'
                  << r8_normal (0.0, 8.0, seed) << '\n'
                  << r8_normal (0.0, 8.0, seed) << '\n'
                  << r8_normal (0.0, 8.0, seed) << '\n';
    }
    

    which gives this output

    8.19933
    1.45505
    -2.42428
    26.9111
    12.8398
    

    And everything looks like it’s working for me for mean = 0.0, sigma = 8.0.

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

Sidebar

Related Questions

I have a function that generates normal random number matrix having normal distribution using
I'm writing a small function to generate values from the Normal distribution using Box-Muller
Is there a difference between generating multiple numbers using a single random number generator
Needing a random number generator that returns a sample from a normal (Gaussian) distribution,
Right, perhaps I should be using the normal Python lists for this, but here
Using an Oracle temporary table does not generate much redo log as a normal
I'm doing sampling from log-normal distribution in Java using Matlab code (with javabuilder java).
Possible Duplicate: Making a standard normal distribution in R Using R, draw a standard
I am using the following code to create a standard normal distribution in R:
I am using the boost::random to generate random velocity values and I want to

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.