Re: Properly formatted large numbers

2010-02-10 Thread Michael Lew
Thanks Terry and Alex.

Yes, I suspect that your suggestions would work, but both involve me working
out how to trap clicks in the datagrid. That seems like more effort than I
can put in at the moment: I've found datagrids to be a bit of a mystery so
far and teaching starts here next week :-(

This is a very nice example from today's list digest that shows why this
issue can be important:

 Hi Jacque, I made the suggestion I did because at 100 Million records plus
 
 100 million? Yes, well...I think I read the zeros wrong.

Should there not be a numberformat setting that formats the numbers for
human readability using the system setting of delimiter?

Regards,
Michael

 Dear Listers
 
 I'm working on some statistical simulations and regularly get output numbers
 with anything from 1 to 7 digits. They are hard to read when they don't have
 the conventional commas separating the thousands and millions. I've written
 a simple function that does the comma formatting for me but it mucks up
 sorting. Of course. (I'm using a datagrid to display the results and live
 sorting is really handy.)
  

Terry Judd responded:
 
 Can you have two columns - one formatted, one not - and somehow apply the
 sort to the unformatted column. I guess the unformatted column would have to
 be of invisible and you'd need to have some way of trapping the selection of
 the column header. You might need Trevor's help there.
 
 Terry...

Alext Tweedy suggested:

 I've not yet used a datagrid, so this is a guess 
 
 can you supply a custom sort function ? Something like
 
 function testLessThan p1, p2
 replace comma with empty in p1
 replace comma with empty in p2
 return p1  p2
 end testLessThan
 
 -- Alex.

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Properly formatted large numbers

2010-02-09 Thread Michael Lew
Dear Listers

I'm working on some statistical simulations and regularly get output numbers
with anything from 1 to 7 digits. They are hard to read when they don't have
the conventional commas separating the thousands and millions. I've written
a simple function that does the comma formatting for me but it mucks up
sorting. Of course. (I'm using a datagrid to display the results and live
sorting is really handy.)

Does anyone have an easy way to deal with this? I'm tempted to use a fixed
pitch font so that larger numbers always look longer, but that would be a
kludgey workaround.

(I note that in OSX the Finder puts separators in the correct places in
large numbers using the settings of the International System Preferences.)

Regards,
Michael
-- 
Michael J Lew
Senior Lecturer
Department of Pharmacology
email: micha...@unimelb.edu.au
phone: +61 3 8344 7812

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: bad interaction between random and word?

2009-04-06 Thread Michael Lew
Mick

I too have been playing with random numbers (I do lots of statistical
programming with Rev, so random(0 is one of my tools).

Your problem sound a very much like it relates to a similar issue that I
came across with random() and arrays a few days ago (quoted below).

I'm pretty sure now that it represents a bug -- a very scary one too,
because it would be completely invisible in many circumstances. Do you want
to post a bug report?

Mike

My post:
 I have struck an unexpected issue with an array. I assumed that the two
 following code snipets would be equivalent, but they are not.
 
 Version 1 
 put random(10)-1 into tnum
 add 1 to iHisto[tnum]
 Version 2
 add 1 to iHisto[(random(10)-1)]
 
 Version 1 does what I expected, and, I guess is more readable and so
 preferable for that reason. However, I can't see why the two versions differ
 in their effects.
 
 Here is the full code of my button for anyone who wishes to try it out (the
 different versions are indicated with comments):
 
 on mouseUp pMouseBtnNo
 put 1 into oreps
 put 100 into ireps
 set the cursor to busy
 repeat oreps
 put 0 into kount
 repeat ireps
 add 1 to kount
 -- **next two lines
 -- put random(10)-1 into tnum
 -- add 1 to iHisto[tnum]
 -- **OR the next one line
 add 1 to iHisto[(random(10)-1)]
 --
 end repeat --inner
 combine iHisto by return and comma
 sort lines of iHisto numeric descending by item 2 of each
 add 1 to ohisto[item 2 of line 1 of iHisto]
 put empty into iHisto
 end repeat --outer
 combine oHisto with return and tab
 sort lines of oHisto numeric ascending by word 1 of each
 put oHisto into fld OutputFld
 end mouseUp
 
 Thanks,
 Michael Lew

Original post:
 Hello, everyone,
 I was working on a project that involved randomness, which seemed to
 be a little off, so I did some testing.
 
 I ran this handler from msgbox:
 on tst2
 repeat with i = 2 to 10
put i into randarg
put 0 0 0 0 0 0 0 0 0 0 into theList
put 1 * i into nRepeats
repeat nRepeats times
   add 1 to word random(randarg) of theList
end repeat
put nRepeats  randarg  theList into line i of fld tmpFld
 end repeat
 end tst2
 
 THE RESULTS:
 
 2 2 10027 10027 0 0 0 0 0 0 0 0
 3 3 9974 9973 9974 0 0 0 0 0 0 0
 4 4 10152 10153 10151 10150 0 0 0 0 0 0
 5 5 10144 10145 10142 10143 10142 0 0 0 0 0
 6 6 9981 9981 9979 9982 9979 9980 0 0 0 0
 7 7 10188 10193 10191 10187 10188 10192 10191 0 0 0
 8 8 10088 10089 10088 10089 10087 10086 10088 10087 0 0
 9 9 9984 9978 9976 9984 9983 9980 9980 9983 9983 0
 10 10 9998 9998 9997 9998   9998 9998 9998 9998
 
 You can see the numbers of repeats are as expected, yet the sum of
 each line SHOULD be exactly the same as the number of repeats, but
 isn't (some above, some below) ... the individual numbers are all
 near to 1 but even nearer to one another in a given line (but
 aren't all equal either).
 
 HOWEVER, when I replace the line
   add 1 to word random(randarg) of theList
 WITH
   put random(randarg) into tmp
   add 1 to word tmp of theList
 
 THE RESULTS ARE:
 
 2 2 9825 10175 0 0 0 0 0 0 0 0
 3 3 9792 9994 10214 0 0 0 0 0 0 0
 4 4 10077 9955 9808 10160 0 0 0 0 0 0
 5 5 9926 10083 10078 9888 10025 0 0 0 0 0
 6 6 9964 10100 9922 9928 10019 10067 0 0 0 0
 7 7 9920 10094 9945 9823 9968 10079 10171 0 0 0
 8 8 10143 10129 10080 9809 10024 9948 9971 9896 0 0
 9 9 9764 10054 10094 9983 10038 10017 9991 10070 9989 0
 10 10 10029 9947 9910 9776 10252 10114 9935 9938 10006 10093
 
 This appears correct ... the sum of each line is (the ones I've
 checked are and estimates of the others are close) the number of
 repeats and the numbers seem randomly sprinkled around 1.
 
 It seems to me that the replacement lines should do exactly the same
 thing as the line they replace.  Is this not working correctly or am
 I missing some knowledge of how it should be working?

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Array issue

2009-04-02 Thread Michael Lew
Dear listers

I have struck an unexpected issue with an array. I assumed that the two
following code snipets would be equivalent, but they are not.

Version 1 
put random(10)-1 into tnum
add 1 to iHisto[tnum]
Version 2
add 1 to iHisto[(random(10)-1)]

Version 1 does what I expected, and, I guess is more readable and so
preferable for that reason. However, I can't see why the two versions differ
in their effects.

Here is the full code of my button for anyone who wishes to try it out (the
different versions are indicated with comments):

on mouseUp pMouseBtnNo
put 1 into oreps
put 100 into ireps
set the cursor to busy
repeat oreps
put 0 into kount
repeat ireps
add 1 to kount
-- **next two lines
-- put random(10)-1 into tnum
-- add 1 to iHisto[tnum]
-- **OR the next one line
add 1 to iHisto[(random(10)-1)]
--
end repeat --inner
combine iHisto by return and comma
sort lines of iHisto numeric descending by item 2 of each
add 1 to ohisto[item 2 of line 1 of iHisto]
put empty into iHisto
end repeat --outer
combine oHisto with return and tab
sort lines of oHisto numeric ascending by word 1 of each
put oHisto into fld OutputFld
end mouseUp

Thanks,
Michael Lew

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Deleting a column ...

2009-02-16 Thread Michael Lew
Dear Bob

You need to set the columndelimiter to comma for your script to work. The
columndelimiter defaults to tab (sensibly, in my opinion).

This works:
on testFunction
 breakpoint
 set the columndelimiter to comma
 put 1,2,3  return  4,5,6 into myVar
 split myVar by column
 delete variable myVar[2]
 combine myvar by column
 put myVar
end testFunction

Michael

 I did this:
 
 ON testFunction
  breakpoint
  put 1,2,3  return  4,5,6 into myVar
  split myVar by column
  delete variable myVar[2]
  combine myvar by column
  put myVar
 END testFunction

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Gaussian pseudo-random numbers -- math issues

2008-10-22 Thread Michael Lew
Dear Tim,

I have an extensive library of statistical maths routines. This handler and
function will get you going with your problem:

on mouseUp pMouseBtnNo
put fld MeanFld into tmean
put fld stdevFld into tstdev
put fld sample sizeFld into n
put fastNormalDeviates(n) into tdevs
split tdevs by return --to make it into an array
multiply tdevs by tstdev --to make the scale the stdev to the desired
value
add tmean to tdevs --to obtain the desired mean
combine tdevs with return
put tdevs into fld outputFld
end mouseUp

function fastNormalDeviates howmany
--returns random deviates from a normal distribution mean 0, stdev 1.
--Fast algorithm simply averages many deviates from uniform
distributions.
--Many times faster than Gasdev-based algorithms.
--Values returned are return-delimited.
if howmany is empty then put 1 into howmany
repeat howmany
repeat 20
add random(1) to tsum
end repeat
put (5000.5-(tsum/20))/645  return after tvals
put empty into tsum
end repeat
delete last char of tvals
return tvals
end fastNormalDeviates

Regards,
Michael

-- 
Michael J Lew
Senior Lecturer
Department of Pharmacology
email: [EMAIL PROTECTED]
Website: http://www.pharmacology.unimelb.edu.au/statboss
phone: +61 3 8344 7812

 I'm interested an a modest statistics demonstration, but I can't
 figure out how do to the math myself.
 
 I'd like to have a few lines of code that produces a sequence of
 numbers. (whole numbers would probably be okay). I'd like to specify
 the number of numbers generated. Let's call that Z.
 
 I'd like also to specify the desired mean and standard deviation. I'd
 like the function (is this a function??) to work in such a way that
 if Z is large, the set of numbers generated, if graphed as a
 frequency distribution, would be normally distributed, i.e., Gaussian.
 
 If Z is rather small, then the mean and standard deviation of the
 numbers produced will would only approximate the desired mean and
 standard deviation. Different runs would produce different actual
 means and standard deviations.
 
 If Z is very small, like 3 or 4, the numbers will look almost random.

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Pricing / entry cost for this tool

2005-11-26 Thread Michael Lew
For some time I have been toying with the idea that software should  
be sold on an income-weighted pricing scheme. If Richard can afford  
to pay more for Rev than Andre, it is in large part because he lives  
and earns in USA rather than Brazil.


I have a couple of educational titles being sold by my University  
that cost the same number of Australian dollars to Harvard as they do  
to universities in Africa. It doesn't seem fair. Perhaps software  
prices could be adjusted for the average (modal) wage in a country.  
It wouldn't harm me for people in low wage countries to pay me almost  
nothing instead of absolutely nothing...




On Nov 26, 2005, at 2:12 AM, Richard Gaskin wrote:




Personally, I think Rev is priced too low.






And Andre replied:


Sh... don't talk that too loud, I am trying to sum some money to
buy a new license and pounds are expensive ;-)




Regards,
Michael

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Pricing / entry cost for this tool

2005-11-26 Thread Michael Lew


On 27/11/2005, at 9:13 AM, [EMAIL PROTECTED]  
wrote:



I have a couple of educational titles being sold by my University
that cost the same number of Australian dollars to Harvard as they do
to universities in Africa. It doesn't seem fair. Perhaps software
prices could be adjusted for the average (modal) wage in a country.
It wouldn't harm me for people in low wage countries to pay me almost
nothing instead of absolutely nothing...



I don't currently make money from writing software -  I make utilities
for my own use. But if I did sell software I don't think I'd be
interested in getting paid 3rd world wages (no offense intended - just
don't know another way to say it) and paying U.S. rates for my  
housing,

food etc.


Making your software available at locally-affordable rates should not  
influence your ability to charge appropriate amounts in your country.  
Locally-affordable would be higher in the USA than in Brazil, and  
higher in Brazil than in Zaire.



If you're rich and don't care, you can give your software
away. I'm sure many of the pros on this list who make money  
programming,
program because they like doing so. I'm sure the RunRev people love  
what

they do. But we all have bills to pay too.

When someone sets a price on a piece of software, I get to decide if
that's worth my money.


You've missed the point. If you only use a US-centric view of  
economic values then you leave out most of the people alive. What is  
offensive about asking a locally-affordable price for a product that  
has no cost for reproduction once produced?



 I don't figure it's their job to make sure I can
afford it -  they don't owe me a thing (which is the attitude that
socialism breeds IMHO, sorry to digress into politics!).


Given how we have gotten to the current world financial model, it  
would be more likely that we owe them than they owe us! Remember that  
the unequal distribution of wealth has come from the unequal  
distribution of power, not the unequal distribution of worth. It  
serves the ruling minority interests to equate means and success with  
moral worth, but we should be able to see beyond it.



Certainly it's
noble to want to see everyone have access to good software. But having
directed a local soup kitchen for 6 years, I can tell you there are
people in the U.S. who are desperately poor. Who would administrate a
system that would charge based on income? I think I would always be  
VERY

poor when I went to make my purchases!


Marty Knapp


I hope that you are kidding about that last comment, or at least  
exaggerating to illustrate a possible abuse of the proposed system.  
At the moment, in your country and mine, the very wealthy pay very  
little tax. The inevitability of abuse and loopholes should not be  
taken as a reason not to attempt to improve something.


Regards,
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution