EADST

C++: Get A Normal Distribution Random Number

C++: Get A Normal Distribution Random Number

#include  < random>

using namespace std;

int GetRamdomNumber(double std=2)
{   
    //work with VS2017, cannot compile in Linux
    random_device rd;
    mt19937 generator(rd());
    std::normal_distribution distribution(0, std);
    double rand_num = distribution(generator);
    //double rand_num = GenerateGaussianNoise(0, std);
    if (rand_num > 3 * std)
    {
        rand_num = 3 * std;
    }
    else if (rand_num < -3 * std)
    {
        rand_num = -3 * std;
    }
    /*int number = std::lround(rand_num);*/
    return rand_num;
}
相关标签
C++
About Me
XD
Goals determine what you are going to be.
Category
标签云
RAR LoRA CV Dataset Google WebCrawler Distillation SQLite Vim XGBoost SPIE Bipartite Python ChatGPT Web TensorFlow uWSGI PDF Cloudreve TensorRT EXCEL 域名 Datetime XML COCO Zip DeepStream C++ Jupyter 关于博主 算法题 Use Ubuntu PDB IndexTTS2 Llama Safetensors Proxy 签证 HuggingFace Tiktoken ResNet-50 Qwen2 GGML transformers Card Qwen Markdown Pandas HaggingFace Bin Claude Bert Quantization PyTorch OpenCV NameSilo Food Anaconda Bitcoin AI ModelScope CTC 腾讯云 净利润 MD5 git Math Animate Vmess Django NLTK Translation Diagram BTC SVR printf mmap Paddle 多进程 公式 多线程 Permission Baidu Michelin Firewall Tensor Conda 音频 LeetCode torchinfo Logo Paper FP32 FP64 继承 Image2Text UNIX API DeepSeek uwsgi FastAPI Video Tracking Pillow Hungarian Docker 报税 OCR Knowledge Nginx Github Random Quantize Disk SQL Miniforge v0.dev FP16 Streamlit Hotel SAM 搞笑 UI Plotly 视频信息 Interview Clash scipy Shortcut Base64 v2ray Magnet JSON Mixtral llama.cpp Git LaTeX LLM TTS tqdm Attention Website Input RGB Data Qwen2.5 飞书 InvalidArgumentError Heatmap WAN Password CEIR Color Algorithm Jetson 阿里云 GIT CUDA VSCode VGG-16 Review ONNX tar GPTQ BeautifulSoup QWEN Transformers LLAMA Land Crawler GoogLeNet hf CLAP Template PyCharm PIP logger 财报 BF16 VPN Excel git-lfs Linux NLP Pickle Pytorch Ptyhon FP8 Breakpoint 版权 Gemma Freesound Augmentation diffusers 证件照 Numpy Plate CSV TSV GPT4 Sklearn Windows CC Hilton Domain Statistics FlashAttention YOLO OpenAI CAM
站点统计

本站现有博文311篇,共被浏览741188

本站已经建立2379天!

热门文章
文章归档
回到顶部