[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: computation and summation is hard [question]

**From**: |
Oliver Heimlich |

**Subject**: |
Re: computation and summation is hard [question] |

**Date**: |
Sun, 08 Nov 2015 11:54:57 +0100 |

**User-agent**: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 |

On 08.11.2015 11:48, Jonathan Camilleri wrote:
>* I am trying to use Octave <http://www.gnu.org/software/octave/> to*
>* compute some basic computational algorithms, and, might need a ride on*
>* someone's back if you do not mind:*
>* *
>* f = @(x) nchoosek(5,x)*0.1.^x*0.9.^(5-x)*
>* f =*
>* *
>* @(x) nchoosek (5, x) * 0.1 .^ x * 0.9 .^ (5 - x)*
>* *
>*>> sum(f([0:5]))*
>* error: Invalid call to nchoosek. Correct usage is:*
>* *
>* -- Function File: C = nchoosek (N, K)*
>* -- Function File: C = nchoosek (SET, K)*
Jonathan,
the function nchoosek seems to allow no evaluation for vectors of K. Use
the function bincoeff instead. Also you might want to use the “.*”
operator instead of “*”.
f = @(x) bincoeff(5,x).*0.1.^x.*0.9.^(5-x)
Best regards
Oliver