NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Random/laplace.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#ifndef NUMCPP_NO_USE_BOOST
31
32#include <algorithm>
33
34#include "boost/random/laplace_distribution.hpp"
35
37#include "NumCpp/Core/Shape.hpp"
38#include "NumCpp/NdArray.hpp"
40
41namespace nc::random
42{
43 namespace detail
44 {
45 //============================================================================
46 // Method Description:
58 template<typename dtype, typename GeneratorType = std::mt19937>
60 {
62
63 boost::random::laplace_distribution<dtype> dist(inLoc, inScale);
64 return dist(generator);
65 }
66
67 //============================================================================
68 // Method Description:
82 template<typename dtype, typename GeneratorType = std::mt19937>
84 {
86
88
89 boost::random::laplace_distribution<dtype> dist(inLoc, inScale);
90
91 std::for_each(returnArray.begin(),
92 returnArray.end(),
93 [&generator, &dist](dtype& value) -> void { value = dist(generator); });
94
95 return returnArray;
96 }
97 } // namespace detail
98
99 //============================================================================
100 // Method Description:
111 template<typename dtype>
116
117 //============================================================================
118 // Method Description:
131 template<typename dtype>
136} // namespace nc::random
137
138#endif // #ifndef NUMCPP_NO_USE_BOOST
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
dtype laplace(GeneratorType &generator, dtype inLoc=0, dtype inScale=1)
Definition Random/laplace.hpp:59
Definition Random/bernoulli.hpp:41
dtype laplace(dtype inLoc=0, dtype inScale=1)
Definition Random/laplace.hpp:112
std::mt19937_64 generator_
generator function
Definition generator.hpp:35
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59