TransWikia.com

Making histogram from a vector

Mathematica Asked by PhysMath on June 24, 2021

I am looking for a nice way to turn a vector-valued function into a set of histograms. I have a function

$$f(t) = (a(t), b(t), c(t), d(t))$$

and would like to plot a histogram of the values of $vert a vert^2, vert b vert^2, vert c vert^2, vert d vert^2$ for $t = 1, dots, 100$. The obvious way to do this is to generate four lists, one for each of $a,b,c,d$ at each of the different $t$ values, then create $4$ separate histograms from these four lists of data. I’m not too experienced in Mathematica, but I would expect there to be a very painless (one or two line) way to do this. Is there?

One Answer

Here it is for two functions a[t] and b[t]. c gives the two lists, and then Histogram plots the histogram.

a[t_] := Sin[t];
b[t_] := Exp[t];
c = {a[#]^2, b[#]^2} & /@ Range[20];
Histogram[#] & /@ Transpose[c]

Correct answer by bill s on June 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP