473,782 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Math functions in VB (or even a dll somewhere) Options

Hello. If this is the wrong group for this, please let me know.
I'll
post it somewhere else.

I've been doing data imports into MS Excel (ver 2007) and using the
CORREL function. What I was wondering was is there anything like
this
in Visual Basic or C#? Or even a DLL? I've got VS2008 and I really
don't want to code the CORREL function by hand if I can just pass off
2 or more array's to a function that already exists.
I've googled and went through the MSDN library and didn't find
anything. Maybe I'm searching wrong, I don't know. Any help would
be
greatly appreciated.
TIA!
Nov 29 '07 #1
5 1895
Hi,
If you are using C# this is the correct group.

First of all you should try to explain what Correl does. Make it easy to the
person trying to help you ;)

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Nondisclosure0 07" <no************ **@gmail.comwro te in message
news:cd******** *************** ***********@g30 g2000hsb.google groups.com...
Hello. If this is the wrong group for this, please let me know.
I'll
post it somewhere else.

I've been doing data imports into MS Excel (ver 2007) and using the
CORREL function. What I was wondering was is there anything like
this
in Visual Basic or C#? Or even a DLL? I've got VS2008 and I really
don't want to code the CORREL function by hand if I can just pass off
2 or more array's to a function that already exists.
I've googled and went through the MSDN library and didn't find
anything. Maybe I'm searching wrong, I don't know. Any help would
be
greatly appreciated.
TIA!

Nov 29 '07 #2
Correlation Coefficient (C#):

public double GetCorrelation( double[] num1, double[] num2)
{
double denominator = (num1.Length - 1) * GetStandardDevi ation(num1) *
GetStandardDevi ation(num2);
double sumxy = 0;
for (int i=0; i<num1.Length; i++)
{
sumxy += num1[i] * num2[i];
}
double numerator = sumxy - num1.Length * GetAvg(num1) * GetAvg(num2);
return numerator / denominator;
}

public static double GetStandardDevi ation(ArrayList num)
{
double SumOfSqrs = 0;
double avg = GetAvg(num);
for (int i=0; i<num.Count; i++)
{
SumOfSqrs += Math.Pow(((doub le)num[i] - avg), 2);
}
double n = (double)num.Cou nt;
return Math.Sqrt(SumOf Sqrs/(n-1));
}

public static double GetStandardDevi ation(double[] num)
{
double Sum = 0.0, SumOfSqrs = 0.0;
for (int i=0; i<num.Length; i++)
{
Sum += num[i];
SumOfSqrs += Math.Pow(num[i], 2);
}
double topSum = (num.Length * SumOfSqrs) - (Math.Pow(Sum, 2));
double n = (double)num.Len gth;
return Math.Sqrt( topSum / (n * (n-1)) );
}

public static double GetStandardDevi ation(double[,] num, int col)
{
double Sum = 0.0, SumOfSqrs = 0.0;
int len = num.GetLength(0 );
for (int i=0; i<len; i++)
{
Sum += num[i,col];
SumOfSqrs += Math.Pow(num[i,col], 2);
}
double topSum = (len * SumOfSqrs) - (Math.Pow(Sum, 2));
double n = System.Convert. ToDouble(len);
return Math.Sqrt( topSum / (n * (n-1)) );
}

public double GetAvg(double[] num)
{
double sum = 0.0;
for (int i=0; i<num.Length; i++)
{
sum += num[i];
}
double avg = sum / System.Convert. ToDouble(num.Le ngth);

return avg;
}

public double GetAvg(int[] num)
{
double sum = 0.0;
for (int i=0; i<num.Length; i++)
{
sum += num[i];
}
double avg = sum / System.Convert. ToDouble(num.Le ngth);

return avg;
}

public double GetAvg(ArrayLis t num)
{
double sum = 0.0;
for (int i=0; i<num.Count; i++)
{
sum += (double)num[i];
}
double avg = sum / System.Convert. ToDouble(num.Co unt);

return avg;
}

-- Have fun!
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"Nondisclosure0 07" wrote:
Hello. If this is the wrong group for this, please let me know.
I'll
post it somewhere else.

I've been doing data imports into MS Excel (ver 2007) and using the
CORREL function. What I was wondering was is there anything like
this
in Visual Basic or C#? Or even a DLL? I've got VS2008 and I really
don't want to code the CORREL function by hand if I can just pass off
2 or more array's to a function that already exists.
I've googled and went through the MSDN library and didn't find
anything. Maybe I'm searching wrong, I don't know. Any help would
be
greatly appreciated.
TIA!
Nov 29 '07 #3
Not that I know, for those who want more information, I have searched for it
on the microsoft website.

http://office.microsoft.com/en-gb/ex...090231033.aspx

Cor

Nov 29 '07 #4
http://www.google.com/search?sourcei...n+coefficient+

See if this helps

Regards,

Trevor Benedict
MCSD
"Nondisclosure0 07" <no************ **@gmail.comwro te in message
news:cd******** *************** ***********@g30 g2000hsb.google groups.com...
Hello. If this is the wrong group for this, please let me know.
I'll
post it somewhere else.

I've been doing data imports into MS Excel (ver 2007) and using the
CORREL function. What I was wondering was is there anything like
this
in Visual Basic or C#? Or even a DLL? I've got VS2008 and I really
don't want to code the CORREL function by hand if I can just pass off
2 or more array's to a function that already exists.
I've googled and went through the MSDN library and didn't find
anything. Maybe I'm searching wrong, I don't know. Any help would
be
greatly appreciated.
TIA!

Nov 29 '07 #5
On Nov 29, 4:25 pm, "Trevor Benedict" <TrevorN...@yah oo.comwrote:
http://www.google.com/search?sourcei...8&rls=GGLG,GGL...

See if this helps

Regards,

Trevor Benedict
MCSD

"Nondisclosure0 07" <nondisclosure. ..@gmail.comwro te in message

news:cd******** *************** ***********@g30 g2000hsb.google groups.com...
Hello. If this is the wrong group for this, please let me know.
I'll
post it somewhere else.
I've been doing data imports into MS Excel (ver 2007) and using the
CORREL function. What I was wondering was is there anything like
this
in Visual Basic or C#? Or even a DLL? I've got VS2008 and I really
don't want to code the CORREL function by hand if I can just pass off
2 or more array's to a function that already exists.
I've googled and went through the MSDN library and didn't find
anything. Maybe I'm searching wrong, I don't know. Any help would
be
greatly appreciated.
TIA!- Hide quoted text -

- Show quoted text -
Thank you for everyone replying. I was kind of looking for something
like a stats.dll that I could use pre-coded functions.

But thanks anyways! I appreciate the code!
Nov 30 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3628
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels deep. In that case you need much more ram than a PC has to store functions calculated in loops so that you do not have to recalculate every time you cycle through the nest of loops. Using a HD for storage to extend ram is much too slow for many...
15
12248
by: Ingmar | last post by:
Simple comparison tests we have performed show that System.Math functions in C# are much slower than corresponding functions in C++. Extreme examples are System.Math.Exp() and System.Math.Tan(), which both seem to average 50 times slower than their C++ counterparts. (Tests are done using optimized Release configurations outside the Visual Studio environment.) Our explanation for this large discrepancy is that C# is an interpreter...
0
1002
by: Mike | last post by:
can anyone explain to me why, given: decimal dec = 84.50M; Convert.ToInt32(dec).ToString() and Math.Round(dec,0).ToString() both correctly output "84"
4
1775
by: markaelkins | last post by:
In the code below I’m trying to figure out how to dynamically perform math functions in a form. To start, I would like to subtract TxtITotal.Text from TxtPTotal.Text and display the results in TxtProLoss.Text before sending the data to the database. I have no idea where to begin. Any help would be greatly appreciated, Thank you,
2
8898
by: kai | last post by:
Hi, How to find the list of SQL math functions in SQL Server 2005? Thanks Kai
4
3361
by: Ney André de Mello Zunino | last post by:
Hello. The following program: #include <list> #include <iterator> #include <algorithm> #include <cmath> #include <iostream>
4
1159
by: Nondisclosure007 | last post by:
Hello. If this is the wrong group for this, please let me know. I'll post it somewhere else. I've been doing data imports into MS Excel (ver 2007) and using the CORREL function. What I was wondering was is there anything like this in Visual Basic or C#? Or even a DLL? I've got VS2008 and I really don't want to code the CORREL function by hand if I can just pass off 2 or more array's to a function that already exists.
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.