EDIT-1
This is a minimal example where an error occurs after 44538 samples generated in d1
upon importing as d2
. Note that if d1
is used as parameter for SmoothKernelDistribution
it is still okay, so there seems to be a problem with the import.
d1 = RandomVariate[NormalDistribution[0, 1], 100000];
Export["d1TEST.txt", d1];
d2 = Flatten[Import["d1TEST.txt", "Table"]];
\[ScriptCapitalD]1 = SmoothKernelDistribution[d2];
SmoothKernelDistribution::invldd: The input data SmoothKernelDistribution[{6617.53,7952.92,<<47>>,7810.37,<<99950>>}] should be a vector or a matrix of real numbers or a valid TemporalData object.
Original post
I have a code in which I write
empiricPDF1 = SmoothKernelDistribution[RandomVariable1Histogram];
d1 = RandomVariate[empiricPDF1, 100000];
isexpan = Transpose[ALPHAHATis].Simplify[PHI];
simis = Table[
isexpan /. {z1 -> d1[[k]], z2 -> d2[[k]]}, {k, 1, nsim}];
timesample1 = simis[[1 ;; All, 688]]
\[ScriptCapitalD]1 = SmoothKernelDistribution[timesample1];
This takes a long time to run since it has to generate a random sample of a big size. I want to save the vector d1 so that I don't have to generate it time and again and also have a constant sample to study. I save the data as
Export["d1_2RVConflictBC.txt", d1];
And then, instead of generating d1, I load it as
d1 = Flatten[Import["d1_2RVConflictBC.txt", "Table"]];
Unfortunately, when I arrive to
\[ScriptCapitalD]1 = SmoothKernelDistribution[timesample1];
I get an error
SmoothKernelDistribution::invldd: The input data SmoothKernelDistribution[{6617.53,7952.92,<<47>>,7810.37,<<99950>>}] should be a vector or a matrix of real numbers or a valid TemporalData object.
which I don't understand. I don't get why it happens. As can be seen in the first attached figure, d1
is the same in both versions of the code and so is the value of time sample. So, I don't understand why the error mentioned above (and in the second attached figure) appears.
empiricPDF1
is not computing. Please add the definition ofRandomVariable1Histogram
? $\endgroup$RandomVariable1Histogram = Flatten[Import["RV1txt.txt", "Table"]];
, it is a 50*1 vector $\endgroup$isexpan = Transpose[ALPHAHATis].Simplify[PHI];
is not evaluating either. Please add enough data to your post to create a minimal working example that is copy-paste-able. Also the data you have posted as a comment can be deleted after you have added it to your post. A presumptive answer to your question is that there is no difference in loading and generating data, if executinglistA==listB
returns True wherelistA
is the generated data and thelistB
is the loaded data. $\endgroup$d1 = RandomVariate[NormalDistribution[0, 1], 1000];
$\endgroup$44538
samples, the output D2 is okay and then it throws an error and I certainly don't know why. I am on v12.2.0 and this could also be version dependent. $\endgroup$