Im trying to make a function named star for an n-pointed star with radius 1, center (0,0) and start line is (0,1) with an angle n(((n-1)/n)*Pi). How??
My end goal is to make the star on the image I posted:
What mathematica functions do I use? graphics, Line, Table??
If possible id love an example :D.
I have not gotten far, the only code I have written is: star[n_] := Graphics[Table[Line[{}, {}], {}]];
Try
star[n_]:=Graphics[Line[Table[{Cos[t*(n-1)^2/n*Pi],Sin[t*(n-1)^2/n*Pi]},{t,0,n}]]];
star[5]
star[13]
Take it apart, look at what just the Table[...] gives you. And exactly why does that use {t,0,n} instead of {t,0,n-1}. And why does it have (n-1)^2/n in it, what does that do? Then look up the documentation for Line[...] and see what it accepts for input and how the output of Table[...] provides that.
Then the challenging part is that you have to reverse engineer my thought process to figure out what I was thinking and how I got to t*(n-1)^2/n*Pi. If you believe you understand all this then see if you can rewrite the calculations in a different way and still get the same result. And then can you find a way to make this much simpler and easier to understand exactly what it is doing and exactly why?
Related
I am building a forestplot with the forestplot package (https://cran.r-project.org/web/packages/forestplot/forestplot.pdf) and have come a long way but I am now stuck on 2 final issues. I am hoping someone here might have helpful advice.
I am presenting the results for my meta-analysis in a forestplot that looks a lot like this example and is based on the script provided here;
example fp
https://cran.r-project.org/web/packages/forestplot/vignettes/forestplot.html
There's 2 things that I cannot seem to figure out
I want a vertical line in the graph for the mean OR
(fp_add_lines is adding a line to the total figure not just the graph part of the figure)
I want to add a second summary to the plot/graph
(fp_append_row works perfect for the first summary, but not for a second)
Anyone here who has experience with this package and knows how to tackle these issues?
I naturally prefer a clean script and not a work-around (overlaying 2 plots to get the vertical line, or manually adding a symbol for the second summary).
Many thanks in advance!
Struggling to find rank values from highest to lowest, please see attached example of what I'm trying to achieve.
My current custom expression is:
Sum([ViolationAmt])
I have tried this:
Sum([ViolationAmt]) over Rank([ViolationAmt])
I've played around with the rank expressions however unable to implement...would be very grateful for some help.
Spotfire Rank Example
I need to make a lot of assumptions here because I don't know anything about your data set or really what your end goal is, so please comment back and/or provide more info in your question if I am off base.
the first assumption is that each row in your dataset represents one, for simplicity, [AccountID] with a [ViolationAmt]. I'm also guessing you want to show the top N accounts with the highest violations in a table, since that's what you've shown here.
so it sounds like you are going to need two calculated columns: one for getting the total [ViolationAmt] per account, and then another to rank them.
for the first, create a column called [TotalViolationAmt] or somesuch and use:
Sum([ViolationAmt]) OVER ([AccountID])
for the second:
Rank([TotalViolationAmt])
it will be useful to read the documentation on ranking functions if you haven't already.
you could probably combine these two into a single column with something like:
Rank(Sum([ViolationAmt]) OVER ([AccountID]))
but I haven't tested this at all. again, if you put in a bit more detail about what you're trying to accomplish it will help you get a better, more detailed answer :)
So I have no problem simplifying using topojson from the command line using the -s flag, however, I can't figure out how to do it from the node module.
I see a topojson.simplify() method, but I can't figure out how it works as there is no documentation.
Does anyone have any insight?
By looking at the simplification tests for topojson, I was able to figure out how to use toposjson.simplify(), but I can't fully claim to know whats going on. You can see the tests on the topojson github.
Basically topojson.simplify takes a topology input and has 2 possible options for simplification, "retain-proportion" and "minimum-area", you can also pass the coordinate system, aka "cartesian" or "spherical", although it can be inferred under most circumstances.
examples:
output = topojson.simplify(topology,{"minimum-area": 2,"coordinate-system": "spherical"});
output =topojson.simplify(topology,{"retain-proportion: 2,"coordinate-system": "spherical"});
I am not really sure exactly what the values you pass into these options mean, however higher values tends to produce more simplification. As a note, retain proportion often returns invalid topologies when passed LineStrings, that may be as intended.
Additionally using the quantization option in topojson.topology can be used to create a smaller, simpler output and may be the best solution to some similar use cases and also doesn't have any clearly documented server API examples anywhere so:
//very simplified, small output
topojson.topology({routes: routesCollection},{"quantization":100});
//very unfiltered, large output
topojson.topology({routes: routesCollection},{"quantization":1e8});
note: the default quantization is 10000 (1e4), so anything less than 10000 will create a smaller output and vice versa.
I was wondering if this type of task is possible and if so how can it could be done or is there a tutorial on this? I believe a task like this involve collocation ,but I am not for sure.
Reverse Geocoding made simple
thats a great tutorial for reverse Geocoding. Adapt what they show you to switch input of a place to input of the coordinate and you will have what you want.
Hey i was working on this little method i guess you call them messing around trying to get my grip on swi-prolog before I have my big project assigned in a week or so at university. Its pretty obvious what it does say i say "colors(yellow,F). it will give me banana, lemon and so on...
colors(C,F):-fruits(F,C)
Now my question is i know i can use list_to_set(F, (something else)), to make the output into one list instead of having to hit ';' to get all of the fruits. THOUGH... is there anyway i can incorporate the list making into the actual method?
cheers!
Okay found out how to:
colors(C,F):-findall(C,fruits(F,C),C).
simple enough, just had to stick it in there. Thanks Anyways!