2
$\begingroup$

I have a data that looks something like.

{{1,1},{12,1},{7,9},{10,14}, ...... } 

I want to see if there is an easy way to apply this array of data into a function like the following:

f:= Beta[1+a,1+b]Beta[12+a,1+b]Beta[7+a,9+b]........

so that I will not have to type them all in

Please help.

$\endgroup$
  • 1
    $\begingroup$ You could also consider Product[Apply[Beta, {a, b} + args], {args, list}]. $\endgroup$ – J. M. will be back soon Jul 17 '15 at 5:31
7
$\begingroup$

You mean like this?

Times @@ Map[ Beta[First[#] + a, Last[#] + b] &, {{1, 1}, {12, 1}, {7, 9}, {10, 14}}]
$\endgroup$
  • $\begingroup$ This worked perfectly! thx! $\endgroup$ – agathusia Jul 27 '15 at 21:44
5
$\begingroup$
f[a_, b_] := 
 Fold[#1*Beta[#2[[1]] + a, #2[[2]] + b] &, 
  1, {{1, 1}, {12, 1}, {7, 9}, {10, 14}}]

f[a, b]

Beta[1 + a, 1 + b] Beta[7 + a, 9 + b] Beta[10 + a, 14 + b] Beta[12 + a, 1 + b]

$\endgroup$
2
$\begingroup$

Or this

d = {{1, 1}, {12, 1}, {7, 9}, {10, 14}};
Times@@Beta @@@ (# + {a, b} & /@ d)

Beta[1 + a, 1 + b] Beta[7 + a, 9 + b] Beta[10 + a, 14 + b] Beta[ 12 + a, 1 + b]

Or if you want a,b,d and Beta all to be parameters to a function f:

f[a_, b_, fn_, d_] := Times@@fn @@@ (# + {a, b} & /@ d)
f[h, i, Beta, {{1, 7}, {2, 8}, {4, 5}}]

Beta[1 + h, 7 + i] Beta[2 + h, 8 + i] Beta[4 + h, 5 + i]

$\endgroup$
  • $\begingroup$ Forgot to multiply 'em all. ;) $\endgroup$ – J. M. will be back soon Jul 17 '15 at 5:30
  • $\begingroup$ Damn, thank you :) $\endgroup$ – image_doctor Jul 17 '15 at 5:31
2
$\begingroup$

More ideas for you:

in = {{1, 1}, {12, 1}, {7, 9}, {10, 14}};

Times @@ Inner[Plus, in, {a, b}, Beta]

Times @@ (Beta[# + a, #2 + b] & @@@ in)

Times @@ MapThread[Beta, in\[Transpose] + {a, b}]
$\endgroup$

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.