Entropy of the distribution as a function of time

In summary: It's probably not doing what you want.I would guess that you want integral to be multiplied by (1-(-1)**len(dim))/intervalsForSphere. That expression will evaluate to 2/intervalsForSphere if len(dim) is even, and -2/intervalsForSphere if len(dim) is odd.In summary, the individual is having trouble finding the entropy in their program and is trying to incorporate it into their code. However, there seems to be an issue with the expression they are using to calculate the integral, as it always evaluates to 2 and may not be doing what they intended. They are seeking further guidance on how to properly incorporate the entropy into their program.
  • #1
alex steve
5
0
I am having an issue with finding the entropy in my program. I was asked to the find the entropy of the distribution as a function of time but i do not know where to start with entropy.

I understand entropy but putting it in my program is where I am stuck

Here is my code:

Python:
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 12 11:15:44 2015"""import matplotlib.pyplot as plt

import random
def Function(D):    #D = dimensions
    sumOfSquare = 0.0
    for i in range(0, len(D)):
        sumOfSquare += D[i]**2
    if sumOfSquare <=1:
        return 1
    else:
        return 0
       
def MonteCarlo(f_n,dim):
    intervalsForSphere = 1000000
    integral = 0.0
    for i in range(0, intervalsForSphere):
        for j in range(0,len(dim)):
            dim[j] = random.random()
        integral += f_n(dim)
    integral = (1-(-1))**len(dim)/intervalsForSphere * integral
    return integral
   
print("10 dimensional unit circle ")
Ten_Dim= list(range(1,10+1))
ten_D_circle = MonteCarlo(Function,Ten_Dim)
print("area:",ten_D_circle)

AreaofCircle = []
x = []

for i in range(1,13):
    D = list(range(1,i+1))
    AreaofCircle.append(MonteCarlo(Function, D))
    x.append(i)

plt.plot(x,AreaofCircle)
plt.xlim([0,13])
plt.xlabel("Dimensions")
plt.ylabel("area")
plt.title("Area of N-dimensional Unit Circle")
plt.show()
 
Technology news on Phys.org
  • #2
alex steve said:
integral = (1-(-1))**len(dim)/intervalsForSphere * integral

Not really about entropy, but are you certain about this expression? It is always evaluated to 2 between the parentheses. Shouldn't it be (1 - (-1)**len(dim)…) or something similar? I'll look further into the code and try to help, but the quoted code above made me scratch my head.
 
  • #3
In addition to what DevacDave said about (1 - (-1)) always evaluating to 2, the expression after '**' probably isn't what you want.
Python:
integral = (1-(-1))**len(dim)/intervalsForSphere * integral

The ** operator is higher in precedence than any of the arithmetic operators, so the expression on the right above is raising 2 to the power len(dim), and is then dividing that result by intervalsForSphere, and finally, multiplying by integral.
 

What is entropy of the distribution as a function of time?

Entropy of the distribution as a function of time is a measure of the randomness or disorder within a system as it changes over time.

How is entropy of the distribution as a function of time calculated?

The entropy of the distribution as a function of time is calculated using a mathematical formula that takes into account the probabilities of different states and the rate at which the system transitions between those states.

Why is entropy of the distribution as a function of time important in scientific research?

Entropy of the distribution as a function of time is important in scientific research because it provides insight into the behavior and evolution of complex systems, such as chemical reactions, biological processes, and physical systems.

Can entropy of the distribution as a function of time be decreased or increased?

Entropy of the distribution as a function of time can only increase or stay the same, according to the second law of thermodynamics. This means that over time, a system will become more disordered and its entropy will increase.

How can entropy of the distribution as a function of time be applied in real-world scenarios?

Entropy of the distribution as a function of time has practical applications in various fields, such as climate science, information theory, and economics. It can be used to predict and understand the behavior of complex systems and to optimize processes for maximum efficiency.

Similar threads

  • Programming and Computer Science
Replies
8
Views
786
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
18
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
4
Views
981
  • Programming and Computer Science
Replies
34
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
6
Views
1K
Replies
3
Views
3K
Back
Top