Previous | Next Removing data from an array of real Home ▸ Documentation ▸ Smile ▸ Computing ▸ Smile's maths ▸ Removing data from an array of real
 To remove items with known indexes from an array of real, use suppress item. set b to {0.0, 1.0, 10.0, 11.0, 20.0, 21.0} as array of real set c to (suppress item {2, 4, -2} from b) c as list of real -- {0.0, 10.0, 21.0} suppress item supports negative indexes. To remove items from an array of real according to some condition, build a mask and use the maskarray command. A mask is an array of real (with the same size as the original array of real) with only 0's and 1's. Usually to make a mask you apply evalformula with a boolean expression. maskarray removes the items which correspond to the 0.0 value in the mask. set b to {0.0, 1.0, 10.0, 11.0, 20.0, 21.0} as array of real set mk to evalformula "x<15" with {x:b} set d to maskarray b with mk d as list of real -- {0.0, 1.0, 10.0, 11.0} You can apply maskarray to a list of arrays of real, provided they have the same size. This is equivalent to masking rows in the matrix whose columns are the original arrays of real. The example below uses masking to perform statistics on conditional expectations of the result of 100,000 draws of two dice. set avs to {} set a to randomarray 100000 range {1, 7} set a to floor a set b to randomarray 100000 range {1, 7} set b to floor b repeat with i from 1 to 6     set expr to "x==" & i & "|y==" & i     set mk to evalformula expr with {x:a, y:b}     set {am, bm} to maskarray {a, b} with mk     set c to addlist am with bm     set end of avs to mean of (statlist c) end repeat set cu to QuickCurve({1, 6}, avs, 0) set cu's pattern style to 1 set cu's pattern size to 12 set cu's fill color to 4 draw cu's window
 Version française Copyright ©2008 Paris, Satimage