I tried to migrate a piece of code from numpy to NumCpp, but the random::seed behavior of NumCpp is inconsistent with that of numpy.
I want to know how to keep the behavior of random::seed in NumCpp consistent with numpy?
Here is my Python code:
import numpy as np
np.random.seed(0)
print(np.random.randn(1, 4))
The output of this code is:
[[1.76405235 0.40015721 0.97873798 2.2408932 ]]
And here is my C++ code:
#include <iostream>
#include "NumCpp.hpp"
using namespace std;
int main(void) {
nc::random::seed(0);
cout << nc::random::randN<float>(nc::Shape(1, 4)) << endl;
return 0;
}
The output is:
[[0.101919, -0.481323, -0.680603, 0.0649879, ]]