Or do I have to loop through and add each integer to a variable and divide by the number of integers in the array?
Is there a way to find the number of integers in an array too (without the traditional way of adding 1 for each iteration in the array)?

It would be nice If Classes with statistical and curve fitting functions were included in Xojo. It would help make Xojo more RAD for scientific and engineering stuff. Maybe in a Xojo.Statisics module or Added to Xojo.Math

I wrote my own very basic classes for some simple single variable stats and another for linear regression but it’s something that felt like that (and more) should be in a RAD enviornment, at least for scientific stuff. At one time I needed the NormsInverse function from Excel. I’m not that mathematically inclined so doing it from scratch was not practical… Likely I found an open source implementation on the net in a language i could translate to RB…

Things like that are one reason why people will chose to use Excel with VBA rather than Xojo for things that are essentially Apps even when they are to be used by others besides themselves.

Writing efficient statistical algorithms is often not easy, so it would be nice to have them built in. From Xojo Inc’s point of view, since they are not UI involved, their should be little to no platform specific dependancies so they should be write once and (assuming no bugs) never have to touch again.

It would help Xojo’s reputation as a serious RAD Tool in a number of fields (depending n what is included) and they could tout them as new features when more are added with each release!

My thought was that for speed this might best be coded under the hood in C…And in that case it would be best to be an in-house thing. Statistical stuff like that is something not many will have the expertise and background to do it and those that need it most are likely using other tools so, it’s hard to see how it flourish as open source.

It’s kind of a chicken and egg thing, If Xojo had those things built in, it would eventually attract new users who need it. Without that there would not be a lot of demand…

I grant you I am speaking about a very specific niche, but the hardest argument for me to make at work for using Xojo at work and getting others to try it, is that Excel has most of the needed Statistical/Math functions included and Xojo does not.

I just through it would be nice if over time Xojo beefed itself up in this area.

It would be nice to see more math and science use in Xojo. I too thought that Xojo was not capable of performing math at acceptable speeds but I now say that Xojo is more than capable without resorting to plugins. I have created modules to do arbitrary precision math using only pure Xojo and am proud to say that many of the functions are faster than the plugin routines that Bob Delaney has. It is true that ‘C’ code will be faster than Xojo given the same algorithm and equivalent coding quality and that you will have to spend time optimizing and finding the best algorithms to perform a particular task. For instance, I spent weeks implementing Fast Fourier Transform multiplication but in the end it allowed me to compute with numbers up to a million digits. Right now I am running an application to factor a 50 digit integer using a quadratic sieve algorithm using pure Xojo code. It also took me weeks to find a quadratic sieve example that I could understand and several weeks to convert it to Xojo but in the end it works really well. The factoring is 10 to 20x slower than the ‘C’ code it emulates but I expect that the upcoming LLVM Xojo backend will make it competitive and I can hardly wait to see if it does.

With the rollout of 64 bit/LLVM in 2015 on all platforms it is time to start thinking about moving code out of plugins and into pure Xojo modules. Code involving math routines should see the largest speedup. It would not surprise me to see a 10x improvement in math intensive code. Image processing is another area that could be Xojo only in 2016 if all goes well.

However, writing math libraries is hard, time consuming work. I do it just because I enjoy coding and it keeps my mind active after retirement. Since there is so little interest in such code, I, like Bob, release what I do for free as open source. I have considered creating a general purpose math toolbox library for Xojo and if I find there is enough interest in having one I will do it.

What are the most needed math capabilities that you think that Xojo has missed??

Complex numbers and matrices I always find use for. For number algorithms I just look up some functions on one of my numerical methods books and create functions out of it. I have used Delaney’s methods before (very grateful to them).

One practical need I often have is to curve fit data to be able calculate results from standards for non linear empirical relationships . Linear regression and log-log linear are straightforward, but for me polynomial fits and their related statistics are not. In the lab I have a instrument’s who response vs amout is best fit in the range I need by a 3rd order curve.

In terms of evaluating data, there are a number number of useful statistics, but it’s been a long time since I personally needed them, and i’m not an expert - I just used what i was told to.

Beside polynomial calibration curve fitting , in the long run it would be good to have modules with most of Excel’s Statistical and Engineering functions, as well as the math functions we don’t already have. BTW For many of those it would make sense for them actually to be classes instead of standalone functions. That’s how I handled some basic single variable stats as well as linear regression.

All that would make Xojo a lot more attractive to those in the sciences and engineering… And of course others would appreciate the financial functions.

The thing is people evaluating Xojo would not know about what available as open source and would tend to evaluate on what is “built in” I think.

Agreed, but I don’t think there is a business case for Xojo to delve into these areas. Looks like the corporate direction is to support additional platforms (IOS and maybe Android or others in the future). I could care less about new platforms. I used to be Windows only but switched to Mac and never looked back. I wish the Xojo staff could grow to the point that emphasis could be on new features (depth vs. breadth) but with the amount of effort required to finish IOS along with LLVM/64 bit I don’t see where a lot of this can be done. I was surprised however to see the new date class capability in the new framework so maybe there is hope that the new framework will bring us new capability in increments.

I’m not sure that open source development within the Xojo community will go anywhere either. I do know it works for some other languages. A good example is the NumPy package developed for the Python language. It has a huge following that I believe attracts people to the language itself. I believe the secret sauce in the Python case is open source language supplemented by open source packages. Xojo being closed source along with commercial plugins make for a hard environment for open source to flourish. I do believe that LLVM can change the playing field in the sense that Xojo can advertise the speed of the product versus products that are not true compilers. Maybe Xojo can get some C/C++ and Python converts.

If I had a New Years wish it would be for Xojo to solicit Kickstarter funding for new platforms and features and grow staff so that some existing staff could build depth into the product (e.g. better listbox, PDF, new text and math capabilities and so forth). It’s time for Xojo to grow but I don’t see that it can without an infusion of money. Otherwise they will remain in bug fix and maintenance hell.

I think that over time the lack of depth (and of course bugs) is likely a major factor in longtime customers leaving… They and their abilities and ambitons grow over time, and they need Xojo to grow/mature too in ways other than just adding platforms, and have the perception that is not happening fast enough.

Exploring those links, if everything available through that page was available for Xojo, Xojo would be a GREAT option for doing scientific computing.[/quote]

Agreed, but I would bet that the annual contribution to that project exceeds the total hours combined of the existing Xojo staff. Not an easy thing to get off the ground without corporate sponsorship or some kind of external investors. There is no Google or other corporate entity that I know of that is willing to contribute to the development or extension of Xojo. From what I have seen, the most successful open source projects (including Linux itself) have at their core some full time paid developers that are funded through corporate donations. To my knowledge this does not exist anywhere in the Xojo community.

Maybe I’ll throw up my Stat classes on my website next week. They could use some cleaning and some documentation. Not sure if I will get around to it.

I wrote them many years ago to do some of the simple statistical calculations usually done in a typical analytical lab. They are nothing great and anybody could write them.

The single variable stats class calculates:
Mean
Variance
Standard Deviation
Standard Error
Relative Standard Deviation
Relative Precent Deviation
Min
Max
n

I did not do median or mode because i did not need them and the class does not store the data (data values are added individually not by array… though i could add that.

The Linear Regression class does Least Squares and has:
Slope
Intercept
n
r
r2
Standard Error values for the Slope and intercept
Mean, variance and Standard Deviation and Standard Error for x and y individually

Function to calculate Y given X
Function to calculate X given Y

[quote=155002:@Rami Hassan]Or do I have to loop through and add each integer to a variable and divide by the number of integers in the array?
Is there a way to find the number of integers in an array too (without the traditional way of adding 1 for each iteration in the array)?

Thanks.[/quote]

I would quickly write my own extends for array, for instance like this (add such function to a module):

[code]Function avg(Extends ar() As Integer) As Double
Dim u As Integer = UBound(ar)
Dim t As Integer = 0

For i As Integer = 0 To u
t = t + ar(i)
Next

Return If(t>0,t/(u+1),0)
End Function
[/code]

Which then can be used in code like this:

[code] Dim numbers() As Integer
numbers = Array(1,2,3,4)

Ubound returns the index of the last element in an array. Arrays are zero-based.

So in the for/next loop, we go to ubound and not ubound+1 in order to sum up all values of the array.

Then, in the return code, we check if total t is greater than 0 and if yes, we divide the total t through the number of elements in the array (which is ubound + 1). Otherwise we just return 0.