我可以通過vbscript注入從flex動作腳本訪問excel數學函數嗎?

[英]Can I access excel mathematical functions from flex action script through vbscript injection?


We are looking to do display some mathematical data in a Flex GUI chart. We need to do plot for two array of data the following.

我們希望在Flex GUI圖表中顯示一些數學數據。我們需要為以下兩個數據數據繪圖。

cross-correlation of both auto-correaltion of each and correlation coefficient

每個自相關和相關系數的互相關

It looks like Flex does not support scientific formula like cross-correlation,auto-correlation and co-relation co-efficient natively. Please correct me if I am wrong or if there are reasonable alternatives at this point.

看起來Flex本身不支持交叉相關,自相關和協同關系等科學公式。如果我錯了或者在這一點上有合理的替代方案,請糾正我。

While looking for alternatives I did come across the article at actionscript.org [--not allowed--]

在尋找替代方案時,我確實在actionscript.org上看到了這篇文章[ - 不允許 - ]

and I am presently trying to see whether I can invoke excel formulas from the actionscript. It looks like there might be some complexity involved in passing the data between flex and vbscript. Will this be the right approach?

我現在正試圖看看我是否可以從動作腳本中調用excel公式。看起來在flex和vbscript之間傳遞數據可能會有一些復雜性。這是正確的方法嗎?

This is for a POC and as such we are looking for a quick hack only.

這是針對POC的,因此我們只是在尋找快速入侵。

3 个解决方案

#1


This is probably way too late, but, well...I got bored :)

這可能太晚了,但是,好吧......我很無聊:)


private function correlationCoeff(X:Array, Y:Array):Number
{
    //correlation coeff between two random variables X and Y is defined as :
    //correlation(X,Y) = Covar(X,Y)/(sqrt(Var(X)) * sqrt(Var(Y)))
    //
    //Var(X) = Covar(X,X);
    //Covar(X,Y) = E((X-xm)(Y-ym)); where xm, ym are the population means.
    return sampleCovar(X, Y)/Math.sqrt(sampleCovar(X, X) * sampleCovar(Y, Y));
}

private function sampleCovar(X:Array, Y:Array):Number { //Sample covariance is Sum((X-xm)(Y-ym))/n-1 //where n is the sample size and xm & ym are sample means. //I'll assume that X and Y are the same size... var total:Number = 0; var xm:Number = sampleMean(X); var ym:Number = (X == Y)? xm : sampleMean(Y); for (var i:int=0; i

private function sampleCovar(X:Array,Y:Array):Number {//樣本協方差是Sum((X-xm)(Y-ym))/ n-1 //其中n是樣本大小,xm&ym是樣本意味着//我假設X和Y的大小相同... var total:Number = 0; var xm:Number = sampleMean(X); var ym:Number =(X == Y)? xm:sampleMean(Y); for(var i:int = 0; i

private function sampleMean(X:Array):Number { //Sample mean = Sum(X)/(sample size) var total:Number = 0; for each(var x:Number in X) total += x; return total/X.length; }

private function sampleMean(X:Array):Number {// Sample mean = Sum(X)/(sample size)var total:Number = 0;對於每個(var x:X中的數字)總數+ = x; return total / X.length; }

I did rather assume you were working with discrete random variables as opposed to doing something funky with signal processing. Bear in mind that sampleCovar won't return the same thing as COVAR in Excel, because Excel uses the biased estimator (i.e. it divides by n rather than (n-1)), but this cancels out when calculating the correlation coefficient.

我寧願假設您正在使用離散隨機變量,而不是使用信號處理做一些時髦的事情。請記住,sampleCovar不會在Excel中返回與COVAR相同的內容,因為Excel使用偏置估計器(即它除以n而不是(n-1)),但在計算相關系數時會取消。

#2


I have never used VBScript, but I know that you can access JavaScript from AS3 and vice versa using the ExternalInterface class in AS3. And as far as I know, you can also access VB functions embedded in web pages from JavaScript. So, it shouldn't be too hard to invoke VB functions from Flash.

我從未使用過VBScript,但我知道您可以使用AS3中的ExternalInterface類從AS3訪問JavaScript,反之亦然。據我所知,您還可以從JavaScript訪問嵌入在網頁中的VB函數。因此,從Flash調用VB函數應該不會太難。

#3


Using ActionScript you can write your own version of COREL to do the calculation. That will be much easier than trying to communicate with Excel. Certainly there is no direct way to communicate with Excel from a Flex app.

使用ActionScript,您可以編寫自己的COREL版本來進行計算。這比嘗試與Excel通信要容易得多。當然,沒有直接的方法可以從Flex應用程序與Excel通信。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/05/25/725aedb0697504df09940f1a80f77442.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com