Re: [go-nuts] Re: recommended statistics package? Requirements: ANOVA, Brown-Forsythe

2023-10-29 Thread 王富民awaw
Hi Jason

Yes, I concur that the function "Levene" named in my package should really 
be called Brown-Forsthe.

I was vacillating between this correct naming versus following the 
nomenclature of scipy 
from
 
which my implementation is numerically tested against.

I looked at a couple of popular statistics software, and it seems that most 
differentiate between Levene and Brown-Forsythe

* JMP 

* SPSS 

* R 

Therefore, perhaps I should not be following scipy and rename my function 
from Levene to BrownForsythe?
I admit I am no statistician and would appreciate some professional 
guidance.
On Monday, 30 October 2023 at 10:41:23 UTC+8 Jason E. Aten wrote:

> 王富民awaw: Very nice.
>
> The Levene function, though, is confusingly named. The Levene test is 
> distinct from the Brown-Forsthe test, so mixing up the names
> seems odd.[1]
>
> [1] quoting 
> https://www.statisticshowto.com/brown-forsythe-test/#:~:text=The%20Levene%20test%20uses%20deviations,a%20test%20that's%20more%20robust.
>   
> below: (see the underlined sentence, underline and bold there is mine)
>
> How the Test Works
>
> Both the Levene and B-F tests transform dependent variables 
>  for use 
> in an ANOVA  
> test.
>  
> The only difference between the two tests is in how those transformed 
> variables are constructed. The Levene test uses deviations from group 
> means , which usually results in a 
> highly-skewed set of data; This violates the assumption of normality 
> .* The 
> Brown-Forsythe test attempts to correct for this skewness  
> by
>  
> using deviations from group medians 
> .*
>  
> The result is a test that’s more robust 
> . In other words, the 
> B-F test is less likely than the Levene test to incorrectly declare that 
> the assumption of equal variances has been violated.
>
> The test works as follows:
>
>- The median is calculated for each factor level group.
>- The median value is subtracted from each dependent variable in the 
>group.
>- An ANOVA 
>
> 
>  is 
>run with the transformed variables. If a factor’s p-value 
>
> 
>  is 
>less than the significance level 
>
> 
>  (usually 
>5%), the population variances are not equal.
>
> W or F statistic?
>
> The test statistic used in a regular ANOVA is an F-statistic 
> .
>  
> The statistic used in an ANOVA with transformed variables is sometimes 
> called a W-Statistic — but it’s really just an F-Statistic with a 
> different name. It should not be confused with the coefficient of 
> concordance W-statistic 
> , 
> which is used to assess agreement between raters.
> Cautions
>
> For the most part, the B-F test is thought to perform as well as or better 
> than other available tests for equal variances. However, Glass and Hopkins 
> (1996 p. 436) state that the Levene and B-F tests are “fatally flawed”; It 
> isn’t clear how robust they are when there is significant differences in 
> variances and unequal sample sizes. Hill et. al (2006) advise repeating the 
> test using a non-parametric 
> 
>  method.
>
> On Monday, October 30, 2023 at 1:08:19 AM UTC 王富民awaw wrote:
>
>> Hi Jan,  Martin, and Jason
>>
>> Thanks for your tips and encouragement for rolling our sleeves.
>> I have put together a small statistics library:
>>
>> stat package - github.com/fumin/stat - Go Packages 
>> 
>>
>> For my own needs, in addition to Brown-Forsythe, I also needed the Welch 
>> t-test and tools for multiple testing, so these are what's in the above 
>> package.
>>
>> On Monday, 30 October 2023 at 07:25:50 UTC+8 Jason E. Aten wrote:
>>
>>> For the ANOVA, I usually 

Re: [go-nuts] Suggestions on optimizing Go GC

2023-10-29 Thread Robert Engels
If the objects are created and discarded you might be able to spawn a new 
process to handle the request - or maybe a bunch - then just kill it and start 
a new process. Possibly use shared memory for constant data. 

This is the poor man’s generational garbage collector. 

> On Oct 29, 2023, at 9:43 PM, Zhihui Jiang  wrote:
> 
> Hi there,
> 
> We have a large-scale recommendation system serving millions of users which 
> is built using Golang. It has worked well until recently when we are trying 
> to enlarge our index or candidate pool by 10X in which case the number of 
> candidate objects created to serve each user request can also increase by 
> 5~10X. Those huge number of objects created on heap cause a big jump of the 
> CPU used for GC itself and thus significantly reduces the system throughput.
> 
> We have tried different ways to reduce GC cost, like using soft memory limit 
> and dynamically tuning the value of GOGC similar to what is described here. 
> Those indeed helped, but they won't reduce the intrinsic cost of GC because 
> the huge number of objects in heap have to be recycled anyway. 
> 
> I'm wondering if you have any suggestions about how to reduce object 
> allocations during request serving?
> 
> Thanks!
> Best
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/a6b8f58f-9452-43e6-9e63-92d944dd0caan%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5741D093-86FC-41F0-BBF1-E4106C92ABC6%40ix.netcom.com.


[go-nuts] Suggestions on optimizing Go GC

2023-10-29 Thread Zhihui Jiang
Hi there,

We have a large-scale recommendation system serving millions of users which 
is built using Golang. It has worked well until recently when we are trying 
to enlarge our index or candidate pool by 10X in which case the number of 
candidate objects created to serve each user request can also increase by 
5~10X. Those huge number of objects created on heap cause a big jump of the 
CPU used for GC itself and thus significantly reduces the system throughput.

We have tried different ways to reduce GC cost, like using soft memory limit 

 and 
dynamically tuning the value of GOGC similar to what is described here 
.
 
Those indeed helped, but they won't reduce the intrinsic cost of GC because 
the huge number of objects in heap have to be recycled anyway. 

I'm wondering if you have any suggestions about how to reduce object 
allocations during request serving?

Thanks!
Best

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a6b8f58f-9452-43e6-9e63-92d944dd0caan%40googlegroups.com.


Re: [go-nuts] Re: recommended statistics package? Requirements: ANOVA, Brown-Forsythe

2023-10-29 Thread Jason E. Aten
王富民awaw: Very nice.

The Levene function, though, is confusingly named. The Levene test is 
distinct from the Brown-Forsthe test, so mixing up the names
seems odd.[1]

[1] 
quoting 
https://www.statisticshowto.com/brown-forsythe-test/#:~:text=The%20Levene%20test%20uses%20deviations,a%20test%20that's%20more%20robust.
  
below: (see the underlined sentence, underline and bold there is mine)

How the Test Works

Both the Levene and B-F tests transform dependent variables 
 for use in 
an ANOVA  
test.
 
The only difference between the two tests is in how those transformed 
variables are constructed. The Levene test uses deviations from group means 
, which usually results in a 
highly-skewed set of data; This violates the assumption of normality 
.* The 
Brown-Forsythe test attempts to correct for this skewness  
by
 
using deviations from group medians 
.*
 
The result is a test that’s more robust 
. In other words, the 
B-F test is less likely than the Levene test to incorrectly declare that 
the assumption of equal variances has been violated.

The test works as follows:

   - The median is calculated for each factor level group.
   - The median value is subtracted from each dependent variable in the 
   group.
   - An ANOVA 
   

 is 
   run with the transformed variables. If a factor’s p-value 
   

 is 
   less than the significance level 
   

 (usually 
   5%), the population variances are not equal.

W or F statistic?

The test statistic used in a regular ANOVA is an F-statistic 
.
 
The statistic used in an ANOVA with transformed variables is sometimes 
called a W-Statistic — but it’s really just an F-Statistic with a different 
name. It should not be confused with the coefficient of concordance 
W-statistic 
, 
which is used to assess agreement between raters.
Cautions

For the most part, the B-F test is thought to perform as well as or better 
than other available tests for equal variances. However, Glass and Hopkins 
(1996 p. 436) state that the Levene and B-F tests are “fatally flawed”; It 
isn’t clear how robust they are when there is significant differences in 
variances and unequal sample sizes. Hill et. al (2006) advise repeating the 
test using a non-parametric 

 method.

On Monday, October 30, 2023 at 1:08:19 AM UTC 王富民awaw wrote:

> Hi Jan,  Martin, and Jason
>
> Thanks for your tips and encouragement for rolling our sleeves.
> I have put together a small statistics library:
>
> stat package - github.com/fumin/stat - Go Packages 
> 
>
> For my own needs, in addition to Brown-Forsythe, I also needed the Welch 
> t-test and tools for multiple testing, so these are what's in the above 
> package.
>
> On Monday, 30 October 2023 at 07:25:50 UTC+8 Jason E. Aten wrote:
>
>> For the ANOVA, I usually just call from Go into R for such things -- at 
>> least until I 
>> can validate if its the right thing to do/ meets the sensitivity/power 
>> needs of the analysis.
>>
>> https://statsandr.com/blog/anova-in-r/
>>
>>
>> https://github.com/glycerine/rmq#and-the-reverse-embedding-r-inside-your-golang-program
>>
>>
>> On Wednesday, October 25, 2023 at 6:48:56 AM UTC+1 Jan wrote:
>>
>>> So cool!
>>> On Monday, October 23, 2023 at 5:44:29 PM UTC+2 Martin Schnabel wrote:
>>>
 Hi, 

 I attempted to translate the linked JS implementation for fun. Maybe 
 someone can use it as a starting point and correct or verify its 
 correctness. 

 https://go.dev/play/p/Wrw2yDRof0z 

 Have fun! 

 On 10/23/23 07:38, Jan wrote: 
 > hi, I did a quick search and I didn't find anything in Go. But 
 looking 
 > at the definition and at one implementation in JS 
 > <
 https://github.com/lukem512/brown-forsythe-test/blob/master/src/brown-forsythe.js>,
  
 it sounds something relatively easy to write and share :)  You can use the 
 R implementation to create some test 

Re: [go-nuts] Re: recommended statistics package? Requirements: ANOVA, Brown-Forsythe

2023-10-29 Thread 王富民awaw
Hi Jan,  Martin, and Jason

Thanks for your tips and encouragement for rolling our sleeves.
I have put together a small statistics library:

stat package - github.com/fumin/stat - Go Packages 


For my own needs, in addition to Brown-Forsythe, I also needed the Welch 
t-test and tools for multiple testing, so these are what's in the above 
package.

On Monday, 30 October 2023 at 07:25:50 UTC+8 Jason E. Aten wrote:

> For the ANOVA, I usually just call from Go into R for such things -- at 
> least until I 
> can validate if its the right thing to do/ meets the sensitivity/power 
> needs of the analysis.
>
> https://statsandr.com/blog/anova-in-r/
>
>
> https://github.com/glycerine/rmq#and-the-reverse-embedding-r-inside-your-golang-program
>
>
> On Wednesday, October 25, 2023 at 6:48:56 AM UTC+1 Jan wrote:
>
>> So cool!
>> On Monday, October 23, 2023 at 5:44:29 PM UTC+2 Martin Schnabel wrote:
>>
>>> Hi, 
>>>
>>> I attempted to translate the linked JS implementation for fun. Maybe 
>>> someone can use it as a starting point and correct or verify its 
>>> correctness. 
>>>
>>> https://go.dev/play/p/Wrw2yDRof0z 
>>>
>>> Have fun! 
>>>
>>> On 10/23/23 07:38, Jan wrote: 
>>> > hi, I did a quick search and I didn't find anything in Go. But looking 
>>> > at the definition and at one implementation in JS 
>>> > <
>>> https://github.com/lukem512/brown-forsythe-test/blob/master/src/brown-forsythe.js>,
>>>  
>>> it sounds something relatively easy to write and share :)  You can use the 
>>> R implementation to create some test datasets. Maybe gonum/stat <
>>> https://godocs.io/gonum.org/v1/gonum/stat> would be a potential home 
>>> for such a function ? What do you think ? 
>>> > 
>>> > cheers 
>>> > On Friday, October 20, 2023 at 10:54:55 AM UTC+2 王富民awaw wrote: 
>>> > 
>>> > Hi follow Gophers 
>>> > 
>>> > I wonder is there a canonical, verifiably correct Go package for 
>>> > statistics? 
>>> > In particular, Go code that does the Brown-Forsythe test of equal 
>>> > variance. 
>>> > Ideally in pure Go, but linking with CGo is OK. 
>>> > 
>>> > A search on Google and pkg.go.dev  does not 
>>> > return helpful results. 
>>> > I wonder is there anything that the community could share? 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> > Groups "golang-nuts" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> > an email to golang-nuts...@googlegroups.com 
>>> > . 
>>> > To view this discussion on the web visit 
>>> > 
>>> https://groups.google.com/d/msgid/golang-nuts/7ee10c0f-8af6-4b31-baaf-ce2ccb9c0211n%40googlegroups.com
>>>  
>>> <
>>> https://groups.google.com/d/msgid/golang-nuts/7ee10c0f-8af6-4b31-baaf-ce2ccb9c0211n%40googlegroups.com?utm_medium=email_source=footer>.
>>>  
>>>
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f0437c9c-5ed5-42ec-ba4d-5dc3ee43ad40n%40googlegroups.com.


Re: [go-nuts] Re: Any option to substitute plug-in package ?

2023-10-29 Thread Jason E. Aten
The RPC and webserver/webclient approaches are well and good. Very 
standard, if high latency.

Other approaches I have used to extend Go dynamically:

a) embed a scripting language:
https://github.com/glycerine/zygomys (my lisp)
https://github.com/google/starlark-go (a python with assign once semantics)
https://awesome-go.com/embeddable-scripting-languages/ # a big long list of 
them
https://github.com/glycerine/rmq # call from/embed R/talk to it over http

b) embed a JIT/dynamic compiler
https://github.com/gijit/gi  # my partial implementation of Go on top of 
LuaJIT to get a REPL. Unfinished/has not been updated in many years.
https://github.com/go-interpreter/chezgo

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/694f3128-c144-4bc0-854c-23e8b2ec9b94n%40googlegroups.com.


[go-nuts] Re: Go called by C: is the goroutine locked to a thread?

2023-10-29 Thread Jason E. Aten
You could also look at the existing Go <-> Python interfaces and see how 
they handle such issues. Might give you hints.

https://github.com/qur/gopy. (python 3.11)
https://github.com/glycerine/pyg (python 3.7.1)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/82d6388a-7694-4a8e-bc65-750178052371n%40googlegroups.com.


Re: [go-nuts] Re: recommended statistics package? Requirements: ANOVA, Brown-Forsythe

2023-10-29 Thread Jason E. Aten
For the ANOVA, I usually just call from Go into R for such things -- at 
least until I 
can validate if its the right thing to do/ meets the sensitivity/power 
needs of the analysis.

https://statsandr.com/blog/anova-in-r/

https://github.com/glycerine/rmq#and-the-reverse-embedding-r-inside-your-golang-program


On Wednesday, October 25, 2023 at 6:48:56 AM UTC+1 Jan wrote:

> So cool!
> On Monday, October 23, 2023 at 5:44:29 PM UTC+2 Martin Schnabel wrote:
>
>> Hi, 
>>
>> I attempted to translate the linked JS implementation for fun. Maybe 
>> someone can use it as a starting point and correct or verify its 
>> correctness. 
>>
>> https://go.dev/play/p/Wrw2yDRof0z 
>>
>> Have fun! 
>>
>> On 10/23/23 07:38, Jan wrote: 
>> > hi, I did a quick search and I didn't find anything in Go. But looking 
>> > at the definition and at one implementation in JS 
>> > <
>> https://github.com/lukem512/brown-forsythe-test/blob/master/src/brown-forsythe.js>,
>>  
>> it sounds something relatively easy to write and share :)  You can use the 
>> R implementation to create some test datasets. Maybe gonum/stat <
>> https://godocs.io/gonum.org/v1/gonum/stat> would be a potential home for 
>> such a function ? What do you think ? 
>> > 
>> > cheers 
>> > On Friday, October 20, 2023 at 10:54:55 AM UTC+2 王富民awaw wrote: 
>> > 
>> > Hi follow Gophers 
>> > 
>> > I wonder is there a canonical, verifiably correct Go package for 
>> > statistics? 
>> > In particular, Go code that does the Brown-Forsythe test of equal 
>> > variance. 
>> > Ideally in pure Go, but linking with CGo is OK. 
>> > 
>> > A search on Google and pkg.go.dev  does not 
>> > return helpful results. 
>> > I wonder is there anything that the community could share? 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> > Groups "golang-nuts" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> > an email to golang-nuts...@googlegroups.com 
>> > . 
>> > To view this discussion on the web visit 
>> > 
>> https://groups.google.com/d/msgid/golang-nuts/7ee10c0f-8af6-4b31-baaf-ce2ccb9c0211n%40googlegroups.com
>>  
>> <
>> https://groups.google.com/d/msgid/golang-nuts/7ee10c0f-8af6-4b31-baaf-ce2ccb9c0211n%40googlegroups.com?utm_medium=email_source=footer>.
>>  
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c4b3018b-08cd-4591-8ba6-ff2ffd40ecc7n%40googlegroups.com.


Re: [go-nuts] Re: Any option to substitute plug-in package ?

2023-10-29 Thread Nagaev Boris
For highly-specific filtering, you might also find
https://github.com/google/cel-go interesting. CEL is statically typed
and declarative.

On Sat, Oct 28, 2023 at 11:48 PM Mike Schinkel  wrote:
>
> I recently started using github.com/yuin/gopher-lua for a project to allow 
> users to add filtering criteria that would be highly-specific to a user, but 
> I would never consider using it for implementing a general-purpose plugin.
>
> Using Lua to develop plugins in Go would be ideal IMO. It is not performant 
> like Go, not type-safe like Go, debugging embedded Lua code is difficult 
> compared to working with Delve and Go, and you will have to ship plugin 
> source code, or embed and write to a possibly hidden directory.
>
> For real-world plugins I'd say stick with Hashicorp's go-plugin or similar as 
> others have recommended, and then only fall back to Lua when you want to 
> allow end-users who are not Go developers to extend your app in small ways.  
> #jmtcw #fwiw
>
> -Mike
> P.S. You could also use JavaScript instead of Lua, and most people are likely 
> more familiar with that. I chose not to use a JavaScript package as I wanted 
> something significantly lighter weight than JS.  OTOH, I am seriously 
> considering switching out Lua and moving to github.com/antonmedv/expr for my 
> use-case as it is even lighter weight still.
>
> On Saturday, October 28, 2023 at 8:50:54 AM UTC-4 alex-coder wrote:
>>
>> Hi all.
>>
>> Of course, in case if anyone is in interest to write  plugins for Go.
>> I found another option for writing plugins by use Lua.
>> I haven't touched the example yet, but I'm giving out the link.
>> https://github.com/yuin/gopher-lua/
>>
>> Thank you.
>>
>> четверг, 3 августа 2023 г. в 15:47:26 UTC+3, alex-coder:
>>>
>>> Hi All,
>>> Currently I walk through the next book about native go development and find 
>>> out that it is possible to use the plugin,
>>> but with limitations, so it became interesting what alternatives there are.
>>>
>>> Thank you.
>>>
>>> четверг, 3 августа 2023 г. в 12:09:21 UTC+3, Christoph Berger:

 WebAssembly comes to mind - see, for example, https://wazero.io/

 A plugin would then be a .wasm binary that can be compiled in any language 
 that supports WebAssembly as target.

 Disclaimer: I have not yet tried this approach.

 On Wednesday, August 2, 2023 at 12:14:15 PM UTC+2 alex-coder wrote:

 Hi All !
 Plug-in package is very interesting, but in case the development under 
 windows it does not work,
 So, any hint to use some option instead will be highly appreciated.

 Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/71ab878f-2ce6-4c73-9e85-e9d29e61d718n%40googlegroups.com.



-- 
Best regards,
Boris Nagaev

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAFC_Vt5UUD7D8S_k6rAUtf00wFObmqiy4T0jAJHDJOrjoTV9WA%40mail.gmail.com.