Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: neat way to program minimum of sum

  • To: mathgroup at smc.vnet.net
  • Subject: [mg75140] Re: [mg75072] neat way to program minimum of sum
  • From: anguzman at ing.uchile.cl
  • Date: Wed, 18 Apr 2007 05:04:25 -0400 (EDT)
  • References: <200704170008.UAA08409@smc.vnet.net>

No, it's not a negative binomial.
Sorry.


Atte. Andres Guzman


"P. Kaminski" <cgenie at gmail.com> ha escrito:

> Hi
> I need to program the following function:
>
> f(t) = max{n>0 : X1 + ... + Xn > t}
>
> where Xi are some random numbers. I've done it using Module and Wile:
>
> x[i_]:=x[i]=Random[]
> f[t_]:=f[t]=Module[{i}, i=1; While[Total[Array[x, i]]<=t, i++]; Return[i-1]];
>
> This works but requires Module and three instructions within. Can it
> be simplified to a true one-liner, preferably with some functional
> programming trick?
>
> Thanks in advance,
> P. Kaminski
>
>



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



  • Prev by Date: Re: neat way to program minimum of sum
  • Next by Date: Re: neat way to program minimum of sum
  • Previous by thread: neat way to program minimum of sum
  • Next by thread: Re: neat way to program minimum of sum