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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:18:45+00:00 2026-05-29T10:18:45+00:00

In the gcc implementation this works trivially; the parameters are only applied as simple

  • 0

In the gcc implementation this works trivially; the parameters are only applied as simple multiply and shift of the actual algorithm’s output. But I could imagine other algorithms to have problems with a special case like this. Should I better build in an external safe-guard, or is it fine to just give std::normal_distribution‘s constructor a 0 as the standard deviation parameter to get a “non-random distribution”, i.e. one that always yields the mean value?

(Performance aside)

  • 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-05-29T10:18:45+00:00Added an answer on May 29, 2026 at 10:18 am

    The standard says the following (§26.5.8.4.4):

    explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0);
        Requires: 0 < stddev.
    

    As such a standard derivation of 0 is explicitly forbidden by the standard and therefore not guaranteed to work. Therefore building an external safeguard seems like a good idea

    Even if the typical implemention would work on a standard derivation of 0 (not sure if that is the case), I could imagine an implementation which tests for such a case and throws an exception when the standard derivation is zero and throws an exception if it is not (to ensure that the code is portable). As an alternative it is possible that the code will divide by the standard derivation somewhere, which would also be problematic with a derivation of 0.

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

Sidebar

Related Questions

I'm sure this question has already been asked in one form or another, but
I know there are questions on here similar to this, but I have not
guys, I've this problem: Normally in C99 GCC (cygwin / MinGW / linux), there
Can lambda expressions be used as class template parameters? (Note this is a very
Just out of interest. How does GCC's C++ implementation handle it's standard number types
This code is for Microchip's PIC32MX microprocessor. Their compiler is essentially GCC 3.4. I
I am using gcc's implementation of openmp to try to parallelize a program. Basically
gcc 4.4.4 c89 Not sure why I am getting this error. In my header
GCC supports Setjump-longjump (sjlj) and Dwarf2 table-based unwinding (dw2) exception handling models. What is
GCC compiles (using gcc --omit-frame-pointer -s ): int the_answer() { return 42; } into

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.