Volume of n-sphere? What is wrong with my version?

3 ビュー (過去 30 日間)
Steve
Steve 2013 年 11 月 11 日
編集済み: the cyclist 2013 年 11 月 11 日
Hello Experts,
I have to calculate the volume of 10-dim sphere.
Here what I did:
N = 100000;
RandVars = -1 + 2*rand(10,N);
V = zeros(N,1);
for i = 1:N
if (sum(RandVars(:,i).^2) < 1)
V(i) = 1;
end
end
% Mean values using the Monte-Carlo method:
M = (1/N)*sum(V,1);
% Error estimation:
C = V - M*ones(N,1);
Error = sqrt((1/(N-1))*sum(C.^2,2));
Please have a look what is wrong as I get M = 0.002. Thanks a lot in advance.
  2 件のコメント
Steve
Steve 2013 年 11 月 11 日
I have changed my code the question is similar but no one is answering...

サインインしてコメントする。

採用された回答

the cyclist
the cyclist 2013 年 11 月 11 日
編集済み: the cyclist 2013 年 11 月 11 日
You forgot to take into account that your bounding hypercube has volume 2^N, not 1, where N is the number of dimensions. (N=10 in your specific case.)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by