1. Basic Statistics with OpenEuphoria
- Posted by rneu May 21, 2020
- 3411 views
How can I do common statistical tests in Euphoria?
Some of these common tests are given on this page: https://cyfar.org/types-statistical-tests
I have seen this page: https://openeuphoria.org/docs/std_stats.html#_3952_statistics but it gives functions for very basic data analysis: mean, standard deviation etc only.
Thanks for your help.
2. Re: Basic Statistics with OpenEuphoria
- Posted by ChrisB (moderator) May 21, 2020
- 3348 views
Hi,
not very helpful, but
- write your own
- create a library
- share it for everyone else to use / criticise / pick apart
- improve it.
- goto 3.
Cheers
Chris
3. Re: Basic Statistics with OpenEuphoria
- Posted by rneu May 21, 2020
- 3410 views
Good option! I would really like to do this if I can get time.
Can I use C libraries here?
For example Apophenia: http://apophenia.info/
or: IMSL C stat library: https://docs.roguewave.com/en/imsl/c/8.6/pdf/C_Stat_library.pdf
Also, is this more easily possible with Phix? (I would have asked on Phix forum but I just can't find it now)
4. Re: Basic Statistics with OpenEuphoria
- Posted by ChrisB (moderator) May 21, 2020
- 3341 views
Hi
Yes you can use c liraries, you may even be able to build a dll. Phix will offer no real advantage here.
You will still have to wrap the libraries, and it may just be easier to write what you need yourself, using those other libraries as guides.
Cheers
Chris
5. Re: Basic Statistics with OpenEuphoria
- Posted by rneu May 21, 2020
- 3373 views
Thanks for guidance.
Just out of curosity, can SWIG ( http://www.swig.org/ ) be used here?
6. Re: Basic Statistics with OpenEuphoria
- Posted by ghaberek (admin) May 21, 2020
- 3349 views
- Last edited May 22, 2020
Can I use C libraries here?
Yes! You'll want to see Dynamic Linking to external code in the docs.
Here are several projects that demonstrate how to wrap C libraries in Euphoria:
For example Apophenia: http://apophenia.info/
or: IMSL C stat library: https://docs.roguewave.com/en/imsl/c/8.6/pdf/C_Stat_library.pdf
Personally, I would go with Apophenia since it seems simpler and it's open source.
Also, is this more easily possible with Phix?
It's more or less the same, but Pete has added some easier support for structures into Phix.
(I would have asked on Phix forum but I just can't find it now)
I think this is effectively the Phix forum.
Just out of curosity, can SWIG ( http://www.swig.org/ ) be used here?
You're welcome to try that, although in my experience the work required to get SWIG working is more involved than just wrapping a library by hand.
You'll find some old SWIG related code on The Archive: https://archive.usingeuphoria.com/
-Greg
7. Re: Basic Statistics with OpenEuphoria
- Posted by rneu May 21, 2020
- 3304 views
Thanks for very useful suggestions.
This link is not working: https://openeuphoria.org/wiki/view/std_dll.html#_5377_dynamiclinkingtoexternalcode.wc
8. Re: Basic Statistics with OpenEuphoria
- Posted by Icy_Viking May 21, 2020
- 3323 views
Thanks for very useful suggestions.
This link is not working: https://openeuphoria.org/wiki/view/std_dll.html#_5377_dynamiclinkingtoexternalcode.wc
The easiest way to wrap a C library in Euphoria is to use a DLL.
--load sigil.dll atom sl --do platform check and load library for the correct platform ifdef WIN32 then sl = open_dll("sigil.dll") if sl = -1 then puts(1,"Failed to open sigil.dll!\n") abort(0) end if elsifdef LINUX or FREEBSD then sl = open_dll("sigil.so") if sl = -1 then puts(1,"Failed to load sigil.so!\n") abort(0) end if end ifdef public constant xslWindow = define_c_proc(sl,"+slWindow",{C_INT,C_INT,C_POINTER,C_INT}) public procedure slWindow(atom width,atom height,sequence title,integer fullScr) atom str = allocate_string(title,1) c_proc(xslWindow,{width,height,str,fullScr}) end procedure
The above is a snippet from a wrapper I wrote for the Sigil library. The process is virtually the same for most C libraries you would want to wrap.
9. Re: Basic Statistics with OpenEuphoria
- Posted by rneu May 21, 2020
- 3307 views
Great. This is exactly what I wanted.
10. Re: Basic Statistics with OpenEuphoria
- Posted by rneu May 22, 2020
- 3286 views
This is very helpful.
Can you also give an example where memory allocation is also involved.
Thanks.
11. Re: Basic Statistics with OpenEuphoria
- Posted by Icy_Viking May 22, 2020
- 3276 views
This is very helpful.
Can you also give an example where memory allocation is also involved.
Thanks.
Here I have an example of memory allocation from my EuSDL2 SDL2 Wrapper.
Stores one or more double words, starting at a memory location. -From the Manual on poke4 function. https://openeuphoria.org/docs/std_machine.html#_5697_poke4
procedure calc_rect(atom rect,integer sx,integer sy,integer tx,integer ty) poke4(rect,sx) poke4(rect+4,sy) poke4(rect+8,tx) poke4(rect+12,ty) end procedure atom drect = allocate(10) --allocates bytes in memory calc_rect(drect,10,10,100,100) --A SDL_RECT is x,y,w,h
12. Re: Basic Statistics with OpenEuphoria
- Posted by rneu May 23, 2020
- 3291 views
Great. Thanks for the code and the link.
Euphoria seems to be a language which is easy and powerful at the same time. Why then it is not more popular? I think it should also be on https://stackoverflow.com/ where many programmers go for solutions and discussions.
13. Re: Basic Statistics with OpenEuphoria
- Posted by ghaberek (admin) May 23, 2020
- 3285 views
Euphoria seems to be a language which is easy and powerful at the same time.
It is! What other languages do you use? We're always looking for help on the language itself and our other related projects.
Why then it is not more popular?
I would say Euphoria peaked in popularity around 2000-2005. Here's breakdown of messages by year. There were more than nearly ten times as many messages in 2004 as there were in 2019.
mysql> SELECT YEAR(created_at), COUNT(created_at) FROM messages GROUP BY YEAR(created_at) ORDER BY COUNT(created_at) DESC; +------------------+-------------------+ | YEAR(created_at) | COUNT(created_at) | +------------------+-------------------+ | 2004 | 11034 | | 2002 | 10186 | | 2001 | 10136 | | 2000 | 9508 | | 2003 | 8719 | | 2005 | 8414 | | 2008 | 8027 | | 1999 | 6857 | | 2007 | 6836 | | 2009 | 6797 | | 2006 | 6523 | | 1998 | 6288 | | 2010 | 3828 | | 2015 | 3352 | | 1997 | 3334 | | 2013 | 3151 | | 2012 | 2987 | | 2011 | 2850 | | 2014 | 2461 | | 2018 | 1615 | | 2016 | 1409 | | 2019 | 1374 | | 2017 | 1042 | | 1996 | 466 | | 2020 | 212 | | 1995 | 12 | +------------------+-------------------+
(The messages table for this forum also includes a complete import of the original mailing list hosted by RDS.)
I think it should also be on https://stackoverflow.com/ where many programmers go for solutions and discussions.
Eh. We're a pretty small community so breaking out to other forums would probably be counter-productive at this point. We do have an active-ish #euphoria channel on Freenode.
I've considered using Discord and Reddit as well (both very popular for developer communities) but right now I think this forum is the best place for us.
-Greg
14. Re: Basic Statistics with OpenEuphoria
- Posted by rneu May 23, 2020
- 3286 views
Thanks for a detailed reply.
Your data regarding popularity of Euphoria can be shown in a graph for clarity: https://imgur.com/a/pHzoN7h (Had to create in Python)
15. Re: Basic Statistics with OpenEuphoria
- Posted by ghaberek (admin) May 24, 2020
- 3278 views
Your data regarding popularity of Euphoria can be shown in a graph for clarity: https://imgur.com/a/pHzoN7h (Had to create in Python)
Wow, that's really neat! I mean, it's kind of sad to see it visualized like that, but it's still neat!
-Greg
17. Re: Basic Statistics with OpenEuphoria
- Posted by rneu May 24, 2020
- 3222 views
Wow, that's really neat! I mean, it's kind of sad to see it visualized like that, but it's still neat!
-Greg
This is the main advantage of languages with many external libraries available - and that may happen if Euphoria is used in mainstream forums like stackoverflow. Just a thought.
18. Re: Basic Statistics with OpenEuphoria
- Posted by petelomax May 24, 2020
- 3318 views
- Last edited Feb 01, 2021
https://imgur.com/a/pHzoN7h (Had to create in Python)
sequence data = {{2004,11034}, {2002,10186}, {2001,10136}, {2000, 9508}, {2003, 8719}, {2005, 8414}, {2008, 8027}, {1999, 6857}, {2007, 6836}, {2009, 6797}, {2006, 6523}, {1998, 6288}, {2010, 3828}, {2015, 3352}, {1997, 3334}, {2013, 3151}, {2012, 2987}, {2011, 2850}, {2014, 2461}, {2018, 1615}, {2016, 1409}, {2019, 1374}, {2017, 1042}, {1996, 466}, {2020, 212}, {1995, 12}} include pGUI.e Ihandle dlg, plot IupOpen() IupControlsOpen() plot = IupPlot("MENUITEMPROPERTIES=Yes, SIZE=640x320") IupSetAttribute(plot, "TITLE", "Messages"); IupSetAttribute(plot, "TITLEFONTSIZE", "10"); IupSetAttribute(plot, "TITLEFONTSTYLE", "ITALIC"); IupSetAttribute(plot, "GRIDLINESTYLE", "DOTTED"); IupSetAttribute(plot, "GRID", "YES"); IupSetAttribute(plot, "AXS_XLABEL", "Year"); IupSetAttribute(plot, "AXS_YLABEL", "Messages"); IupSetAttribute(plot, "AXS_XFONTSTYLE", "ITALIC"); IupSetAttribute(plot, "AXS_YFONTSTYLE", "ITALIC"); IupSetAttribute(plot, "AXS_YTICKSIZEAUTO", "NO"); IupSetAttribute(plot, "AXS_YTICKMAJORSIZE", "8"); IupSetAttribute(plot, "AXS_YTICKMINORSIZE", "0"); IupPlotBegin(plot) data = sort(data) for i=1 to length(data) do IupPlotAdd(plot, data[i][1], data[i][2]) end for {} = IupPlotEnd(plot) dlg = IupDialog(plot) IupCloseOnEscape(dlg) IupSetAttribute(dlg, "TITLE", "Messages") IupMap(dlg) IupShowXY(dlg,IUP_CENTER,IUP_CENTER) IupMainLoop() IupClose()
19. Re: Basic Statistics with OpenEuphoria
- Posted by rneu May 24, 2020
- 3206 views
Very nice.
GUI capabilities of Euphoria should also be mentioned on home page https://openeuphoria.org/index.wc since most visitors look for this aspect when evaluating a new language.
GUI code like this should also be included on "Sample Code" page: https://openeuphoria.org/wiki/view.wc?page=SampleCode
Code similar to this should also be added to http://rosettacode.org/wiki/Plot_coordinate_pairs (where there is no Euphoria entry currently).
- Rneu