2014-07-23 3 views
2

자바 스크립트 (d3 및 dc 라이브러리) (R의 밀도 함수와 유사 함)를 사용하여 데이터 집합의 확률 밀도 함수를 만들려고하지만 어떻게 할 수 있습니까? 그것.자바 스크립트 d3 및 dc로 확률 밀도 함수

할 수 있습니까?

감사

PD : jqplot이 있습니다으로 : 마지막으로 http://services.mbi.ucla.edu/jqplot/examples/kcp_pdf.html

+0

점을 계산하고 그 점을 그려야합니다. 전자의 경우 이미 존재하는 것을 사용할 수 있습니다. jqplot. –

+0

문제는 직류로 해결해야한다는 것이 었습니다. KDE ([science.js] (https://github.com/jasondavies/science.js))를 구현 한 라이브러리를 발견했으며이를 사용하여 결과가 좋았습니다. 감사! – fhuertas

답변

2

, 내가 (science.js 라이브러리에서 구현)에 KDE 알고리즘을 수행 할 수 있어야

어떻게 이제까지 라이브러리 직류 필요 데이터가 수정되었는지 확인하십시오. 모든 외모와 빈도를 가진 객체에서 데이터가 축소되면 객체는 각 모양에 대한 항목이있는 배열로 변형되어야합니다. DC는 페인트 할 그룹이 필요하기 때문에 그룹이 필요합니다.

내 솔루션은있다 :

// Creating the group 
var group = dimension.group().reduceSum(); 
...... 
// Process the object. 
groups = group.all() 
var newValues = [] 
for (var i = 0; i < groups.length; i++) { 
    for (var j = 0; j < groups[i].value;j++){ 
     if (groups[i].key == "null" || 
      groups[i].key == null || 
      (groups[i].key - start < 0) || 
      (groups[i].key - end > 0)) { 
     } else { 
      newValues.push(parseFloat(groups[i].key)) 
     } 
    } 
} 
..... 
// Creating the new data that represent a density function. 
var kde = science.stats.kde().sample(newValues); 
// I have replaced the bandwidth method (Multivariate Density Estimation) 
// because this method works better than previous (Density Estimation) 
// min and max are calculated previously 
kde.bandwidth(science.stats.bandwidth.nrd0); 
var frequency = Math.abs(parseFloat(max) - parseFloat(min))/512 
var newData = kde(d3.range(min,max,frequency)); 

..... 
// The array that is inside of the group is a reference (obviously but it is important) 
// Deleting the contains of the array 
groups.splice(0,groups.length) 
// add the new data 
for (var key in newData) { 
    groups.push({key:newData[key][0],value:newData[key][2] 
}) 

구현은 그 일이 내가 뭘 프레임 워크 (repository)에서 볼 수 있습니다.

관련 문제