Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11964 > unrolled thread

Re: pattern matching

Started byDana DeLouis <dana01@me.com>
First post2012-10-06 06:06 +0000
Last post2012-10-06 06:06 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: pattern matching Dana DeLouis <dana01@me.com> - 2012-10-06 06:06 +0000

#11964 — Re: pattern matching

FromDana DeLouis <dana01@me.com>
Date2012-10-06 06:06 +0000
SubjectRe: pattern matching
Message-ID<k4ohp9$i6a$1@smc.vnet.net>
> Count[Table[RandomInteger[], {n}], 1]/n, {n, 100, 1000, 10}], x_ < .5]

Hi.  Here's one way.

t=Table[Count[Table[RandomInteger[],{n}],1]/n,{n,10,15,1}]

{7/10,4/11,1/2,7/13,3/7,8/15}

Count[t, n_/; n<.5]
2

As a suggestion, note the following with 0 / 1's

Mean[{1,1,0,0,0}]
2/5

Perhaps:

t=Table[Mean[RandomInteger[{0,1},n]],{n,10,15,1}]
{1/2,2/11,2/3,5/13,4/7,2/15}

Count[t, n_/;n<.5]
3

= = = = = = = = = =
HTH  :>)
Dana DeLouis
Mac & Mathematica 8
= = = = = = = = = =




On Friday, October 5, 2012 2:43:42 AM UTC-4, Daniel S wrote:
> Consider the following code:
> 
> 
> 
> Count[Table[
> 
>   Count[Table[RandomInteger[], {n}], 1]/n, {n, 100, 1000, 10}], 
> 
>  x_ < .5]
> 
> 
> 
> I want to count the number of times there are occurrences less than .5 but some how I am not specifying the right pattern.  Any suggestions on getting right?

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web