Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 24 commits into
base: feedback
Choose a base branch
from
Open

Feedback #1

wants to merge 24 commits into from

Conversation

github-classroom[bot]
Copy link

@github-classroom github-classroom bot commented Oct 25, 2022

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to main since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to main since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to main. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @Sherlychn @Javenieyong @Venicechua

github-classroom bot and others added 24 commits October 25, 2022 11:49
Solution A trial 1
solution updated.
Solution is updated.
Minor Changes
Solution is updated
Solution is updated.
Solution is updated.
Method A Solution Part 1
Method B solution updated
Method C updated.
Updated Solution on Probability
Updated Solution A
Solution for Method B is updated.
Method C solution is updated.
Method C is updated.
Method C updated.
Method A solution updated.
Method B and Method C are updated.
updated solution
Final Solution is updated
Referencing is updated.
@AfiqahSofry
Copy link

Hello! Well done with coming up with your codes! However, it would be great if you could visualise the random endpoints and random chords using ggplot. Also, it could be better to print the values of the probabilities on the console.

@alyaadis
Copy link

Hi! Nice work. However, I think it would be better to plot/visualise the chords and endpoints (circle) by using ggplot.
Also, maybe add more comments to make the code clearer and print the probabilities for each method as the output, so it would be easier to see instead of looking it from the global environment.

@azwaien
Copy link

azwaien commented Nov 12, 2022

Hello, the code seems fine.

However, the solution is provided in the environment section but there is no output. :(

Also, I tried to change the n from n = 100 to n = 100,000 (for checking) but the probability doesn't seem to converge. :(

Overall, Well done! and your code styling seems decent as well :D

@Alidinie
Copy link

The coding style is easy to understand. The probability for all methods can be seen in the environment but it would be nice if you guys printed the probability values and used ggplot to visualise the chords.

@wafi0
Copy link

wafi0 commented Nov 12, 2022

Good effort in writing the code. The comments make it easier to understand.

It's unfortunate that the expected outcome (expected Pr(A) values [0.33, 0.5, 0.25]) couldn't be reached, but at least the code runs without any syntax errors and some parts do work correctly e.g. applying trigonometry, finding probability from existing samples

Suggestion:

Put variables inside round brackets to print their values in the console
E.g

# Estimated probability of chord being longer than triangle side-----------------
probEstA=mean(lengthA>lengthSide) # Method A
probEstB=mean(lengthB>lengthSide) # Method B
probEstC=mean(lengthC>lengthSide) # Method C

(probEstA)
(probEstB)
(probEstC)

EDIT:

Just want to quickly bring up the error that prevented the expected results, in case it's found to be useful. It's within the chord endpoint computations for methods A (which is actually method C in the instruction) and B.

Original code snippet:

# Calculate Chord endpoints - Method A
xA1 = (ax+pA)*(cos_angleA+qA)*(sin_angleA)
yA1 = (ay+pA)*(sin_angleA-qA)*(cos_angleA)
xA2 = (ax+pA)*(cos_angleA-qA)*(sin_angleA)
yA2 = (ay+pA)*(sin_angleA+qA)*(cos_angleA)
# Calculate Chord endpoints - Method B
xB1 = (ax+pB)*(cos_angleB+qB)*(sin_angleB)
yB1 = (ay+pB)*(sin_angleB-qB)*(cos_angleB)
xB2 = (ax+pB)*(cos_angleB-qB)*(sin_angleB)
yB2 = (ay+pB)*(sin_angleB+qB)*(cos_angleB)
# Original results
> (probEstA)
[1] 0.81553
> (probEstB)
[1] 0.65221
> (probEstC)
[1] 0.33436

Correct code snippet:

# Calculate Chord endpoints - Method A
xA1 = (ax+pA)*cos_angleA + qA*sin_angleA
yA1 = (ay+pA)*sin_angleA - qA*cos_angleA
xA2 = (ax+pA)*cos_angleA - qA*sin_angleA
yA2 = (ay+pA)*sin_angleA + qA*cos_angleA
# Calculate Chord endpoints - Method B
xB1 = (ax+pB)*cos_angleB + qB*sin_angleB
yB1 = (ay+pB)*sin_angleB - qB*cos_angleB
xB2 = (ax+pB)*cos_angleB - qB*sin_angleB
yB2 = (ay+pB)*sin_angleB + qB*cos_angleB
# More precise results
> (probEstA)
[1] 0.24882
> (probEstB)
[1] 0.5001
> (probEstC)
[1] 0.33056

Above is the expected combination of approximate Pr(A) values for random midpoints, random radial points, and random endpoints respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants