i am new. i need help. kindly answer.

2 ビュー (過去 30 日間)
Rana zain
Rana zain 2020 年 11 月 28 日
コメント済み: Rana zain 2020 年 11 月 28 日
I want to ask is there a way to write a code to integrate the function f(x,y,z) over a sphere using Monte-Carlo method in three dimensions.
  6 件のコメント
John D'Errico
John D'Errico 2020 年 11 月 28 日
With some effort, I can certainly think of problems where only Monte Carlo makes sense. But the number of times I have encountered such a problem over my career is zero. And that suggests this is homework.
Rana zain
Rana zain 2020 年 11 月 28 日
Thanks guys i got it.

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

回答 (1 件)

John D'Errico
John D'Errico 2020 年 11 月 28 日
編集済み: John D'Errico 2020 年 11 月 28 日
If this is homework? It very possibly is, because there are relatively few good reasons I can think of to solve any integration problem over a sphere using Monte Carlo. So if it is homework, then you need to do your own homework. At least make some effort.
Regardless, even if this is homework, it is still trivial. Just generate points uniformly distributed over the sphere. Then add up function values at those points. (Be careful to scale by the volume of the sphere.) WTP? I can think of several ways to generate uniformly distributed random points inside a sphere. You should even be able to use a weighted Riemann sum, if your generation scheme was not uniform.
The problem is, Monte Carlo is not very efficient as a method. You will gain far more accuracy in your result by using any of a variety of schemes for integration over a simple domain.
The only circumstance when I could see using Monte Carlo on a spherical domain is if your function is itself strongly discontinuous over the domain of the sphere, with many discontinuities, derivative singularities, etc.
So in any case, you need to convince me this is not homework. And then you need to convince me why it is that you think you really need to use Monte Carlo. I won't spend the time telling you how to solve a problem poorly.
  1 件のコメント
Rana zain
Rana zain 2020 年 11 月 28 日
Thanks for your help. i solved it myself. I just needed a start and confirmation if this is possible on MATLAB.

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

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by