# NMaxmize with a list of variables

I want to use NMaximize to find the maximum value of a function with multiple variables. The problem is I would like to set this up so the number of variables is only decided when the function sees the data. So I have:

NMaximize[{F[data,a1,a2],a1>0,a2>0},{a1,a2}]


when there are data from two genes. But would like the function to be

NMaximize[{F[data,a1,a2,a3],a1>0,a2>0,a3>0},{a1,a2,a3}]


if there are 3 genes...etc Any way to set this?

-

func[syms__Symbol] := NMaximize[{F[data, syms], Thread[{syms} > 0]}, {syms}]

NMaximize[{F[data, q, r, s, t], {q > 0, r > 0, s > 0, t > 0}}, {q, r, s, t}]

Thanks for this. I've almost got it to work using pList = Table[Symbol["a"<>ToString[i]],{i,1,n}] to generate my list of variables, but there's a complication I'm still working on. – user6799 Apr 10 '13 at 16:48
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.5479536056518555, "perplexity": 867.9849703104809}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2016-22/segments/1464049273643.15/warc/CC-MAIN-20160524002113-00085-ip-10-185-217-139.ec2.internal.warc.gz"}