I have the following Julia code to generate synthetic data.
using Statisticsusing Randomseed_value = 42Random.seed!(seed_value)f(x, t) = 3.2 * (x + 0.2t)n_meas = 20X = zeros(n_meas, 2)X[:, 1] .= 1 * rand(n_meas)X[:, 2] .= 2 * rand(n_meas)u_meas = f.(X[:, 1], X[:, 2])u_meas .+= 0.05 * mean(u_meas) * randn(n_meas)print(u_meas)What is the correct python code that will generate the same dataset (u_meas) as above?
I tried the code below which did not print out the same results as my Julia code
import numpy as npnp.random.seed(42)def f(x, t): return 3.2 * (x + 0.2 * t)n_meas = 20X = np.zeros((n_meas, 2))X[:, 0] = 1 * np.random.rand(n_meas)X[:, 1] = 2 * np.random.rand(n_meas)u_meas = f(X[:, 0], X[:, 1])u_meas += 0.05 * np.mean(u_meas) * np.random.randn(n_meas)print("u_meas:")print(u_meas)