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 CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by