51 reputation
5
bio website
location
age
visits member for 1 year, 9 months
seen Jun 6 at 10:35

May
27
comment How to pass a list as function argument?
Thanks Jacob. I've written the following and it seems to work. Do you think this is better or do you think it will be slow too and should I find another way? lFreqPhylo[a_, Q_, b_, p_] := Sum[Log[freqFunction[r[[p]][[i]], L[[p]][[i]], a, Q, b]], {i, 1, nbranches[[p]]}]; lFreqPhylo2[listA_, listB_, Q_] := Total@MapThread[ lFreqPhylo[#1, Q, #2, #3] &, {listA, listB, Range[Length@listA]}]; lFreq[A_, B_, Q_] := Evaluate[lFreqPhylo2[A, B, Q]];
May
27
awarded  Editor
May
27
comment How to pass a list as function argument?
Jacob, I have now changed the original question such that it contains all the sub-questions I had. Sorry for the confusion.
May
27
comment How to pass a list as function argument?
You're absolutely right, I've now edited it.
May
27
revised How to pass a list as function argument?
added 402 characters in body; edited title
May
27
comment How to pass a list as function argument?
Kuba, Well, problem is I have two lists and need to pass an index of the list as an argument. So following your advice, having defined two lists, A = {a1,a2}; B = {b1,b2}; I did f1[a_, b_, Q_] := (a b)^2/Q; f2[Q_, a__, b__] := Total[MapThread[f1[#1, #2, Q] &, {A, B}]]; and now it works. But what if I have f1[a_, b_, Q_,i_] := (a b)^2/Q i where i is the index of the element of the list (1 or 2)? How do I define f2 then?
May
27
asked How to pass a list as function argument?
Oct
27
awarded  Popular Question
May
22
awarded  Scholar
May
22
comment Weird vertical line when trying to plot a histogram
Thanks a lot Sjoerd, it's exactly what I needed!
May
22
accepted Weird vertical line when trying to plot a histogram
May
21
asked Weird vertical line when trying to plot a histogram
Dec
6
comment How to generate a RandomVariate of a custom distribution?
This is actually very helpful, thanks!
Dec
6
awarded  Supporter
Nov
1
awarded  Student
Nov
1
asked How to generate a RandomVariate of a custom distribution?