1
$\begingroup$

I have a problem with the Flatten function. First here below data tables.

tsample = Table[jj, {jj, 0.1, 0.25, 0.01}]
ε = EstimatedDistribution[tsample, TriangularDistribution[{min, max}]]
sample = Table[ii, {ii, 0.1, 0.35, 0.01}]
ω = EstimatedDistribution[sample, TriangularDistribution[{min, max}]]

Now, I need to have a Flatten for ω and ε, but I'm not able to find the right way. I wrote it like this but I don’t think it's the right way:

εω = 
  Flatten[
    Table[
      Table[{sample[[ii]], tsample[[jj]]}, {jj, 1, Length[tsample]}], 
      {ii, 1, Length[sample]}], 
    1]

I would appreciate your help!

$\endgroup$
2
$\begingroup$
tsample = Table[jj, {jj, 0.1, 0.25, 0.01}];

ε = 
 EstimatedDistribution[tsample, TriangularDistribution[{min, max}]]

(* TriangularDistribution[{0.0750068, 0.274993}] *)

dataε = RandomVariate[ε, 1000];

Show[
 Histogram[dataε, Automatic, "PDF"],
 Plot[PDF[ε, x], {x, 0, 0.3}]]

enter image description here

sample = Table[ii, {ii, 0.1, 0.35, 0.01}];

ω = EstimatedDistribution[sample, TriangularDistribution[{min, max}]]

(* TriangularDistribution[{0.0621028, 0.387897}] *)

dataω = RandomVariate[ω, 1000];

Show[
 Histogram[dataω, Automatic, "PDF"],
 Plot[PDF[ω, x], {x, 0, 0.45}]]

enter image description here

It is not clear to me what you are trying to accomplish. If you want a table of your underlying data then

Prepend[(Transpose@PadRight[{tsample, sample}]) /. 0 -> "-", {"tsample", 
   "sample"}] // Grid

enter image description here

If you want random data drawn from your distributions then

With[{n = 15},
 Prepend[Transpose[
    {RandomVariate[ε, n], 
     RandomVariate[ω, n]}], {ε, ω}] // Grid]

enter image description here

$\endgroup$
3
  • $\begingroup$ Hi Bob, Thanks a lot. So i would like to generate some couples of {ε, ω} Following a triangular Distribution and using data from sample and tsample (the two data tables above). $\endgroup$
    – EmilioDas
    May 15 '20 at 20:34
  • 1
    $\begingroup$ I do not understand what you are trying to do. ε and ω are triangular distributions -- you defined them as such. The examples show how to generate random values from those distributions. The plots compare histograms of sampled data with the PDFs of the distributions. $\endgroup$
    – Bob Hanlon
    May 15 '20 at 21:33
  • $\begingroup$ Dear Bob, my bad, i didn't understood your method. now its clear, this is exactly what i was looking for. thanks a lot for the help $\endgroup$
    – EmilioDas
    May 16 '20 at 3:12
1
$\begingroup$

Try Outer[List, sample, tsample]

$\endgroup$
2
  • $\begingroup$ Hi xinbae, Thanks! But i sample and tsample are two tables. My flatten Function must contain epsilon and omega which are Following a triangular distribution and using data from sample and tsample. This is the hard part and i've tried find the good way to solve this problem but Nothing till now. Do you have any idea ? $\endgroup$
    – EmilioDas
    May 15 '20 at 14:50
  • $\begingroup$ Sorry. I don't quite understand what you mean. $\endgroup$
    – XinBae
    May 15 '20 at 23:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.